2 DID's from 1 trunk (localphone) => inbound routing?

Hey folks,

I am kinda new on this forum, and on the whole freepbx/asterisk stuff.

I have setup a asterisk/freepbx installation with 3 hardphone and 1 softphone. I have setup 2 trunks:

  1. voipcheap: will be used for outbound calls only
  2. localphone: will be used for inbound calls only (DID’s)

I am not using any classic phonelines.

With localphone, I ordered 1 DID. I made a new (temp) inbound routing that routes al inbound calls to extension 602.

I want to order another DID with localphone, and want to route as following:

DID1 to ring group 600 (contains 601,602 and 603)
DID2 to extension 602.

When I order another DID, wil asterisk then “know” wich DID is used when someone calls me? Because at localphone, the DID will be connected with my VOIP number (6364612).
Or is the easiest way to create a second account at localphone?

Thanks for the info!!

This is what inbound routes is for.

Routing calls to FreePBX destination based on the DID received.


thanks for the feedback.

I know that is possible with inbound routing, but I’m not shure it can be done with the LocalPhone DID’s.

My inbound phone number is like +3238082288. But when I receive the call in FreePBX, I only see my VOIP number (6364612) in the logs.

So when I order a second DID, my guess is that in FreePBX, bot DID numbers will only show up as “6364612”, because Localphone is not sending the DID with incomming call’s.
If that is the fact, I guess FreePBX won’t know the difference between the 2 DID’s and I won’t be able to route them separate?

It’s not a DID if they don’t send the DNIS digits (Dialed Number Identification Service).

It they treat it as a separate account you can route it that way. Numerous examples exist on the site. Other so called carriers do this.

Are the numbers so cheap that it is worth the hassle?

Ok I see. So only option would be taking separate accounts then.

I pay 1 dollar per number a month.
Do you have any other suggestion for cheap (real) DID’s that offer Belgian numbers?



check the SIP header of the inbound DID. Some providers put the DID in the TO: field. If that is the case, you can extract and route on it but that requires you run it through a context that will do that.

See the context:

exten => s,1,Goto(from-pstn,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)

that is in extensions.conf in 2.7 (and has been checked into earlier releases but has not yet been published out at the time I am writing this.

If you determine the DID is in the TO: header then you can simply use “context=from-pstn-toheader” for your trunk configuration.

The from-pstn-toheader context didn’t work for me because my TO header was simply [email protected] My DID was in another header, though, called “x-caller-DNIS”.

My provider is Teliax. Your provider may put this information in a SIP header of a different name, such as “x-caller”. You can find it by turning SIP debug on (“sip set debug” on asterisk CLI) and placing a call to your number and subsequently grepping for your number in the log (“tail /var/log/asterisk/full -n 50000 |grep 8005551212” in a linux shell).

Once you know the header name, create a new context in your extensions_custom.conf like the below, but be sure to change the name of the context and the name of the SIP header appropriately.

exten => s,1,Goto(from-pstn,${SIP_HEADER(x-caller-dnis)},1)

Last, direct your incoming calls to that context by adding “context=custom-fix-teliax-DID” to your peer details of your trunk configuration.

Disclaimer: I am by no means an expert, so if Philippe replies and says this is a bad idea, believe him, not me. :slight_smile: That being said, this solved my problem and works great for me with no side effects that I have noticed.

could someone troubleshoot why my localphone account is not receiving calls?

but it seems like I give up, anyone here with suggestions on how to get the incoming work. The outgoing is working fine. Here is my Configuration for the

Sip Trink:

Trunk Name: localphone-out
PEER Details:
authuser=[my sip]
username=[my sip]
fromuser=[my sip]
secret=[my sip password]

USER Context:localphone-in

USER Details:


Register String:
[my sip]:[my sip password]@localphone.com/[my sip]

now, I added this configurations in this file: extensions_custom.conf

exten => [my sip],1,Dial(SIP/sipphone,60,tr) ; phone must be registered
exten => [my sip],2,Hangup

I also tried to make “USER Details” empty but it is still the same.
Could anyone here has the same sitution with solution?