Transfering incoming calls to a different extenstions depending on the called number


I am using asterisk+freepbx on a debian server. I have 4 trunks. I am using one trunk trunk_out for outgoing calls. So everybody who is trying to call an external numbers will use trunk_out. The 3 other trunks (freephonie, and 2 ippi) trunk_in[1-3]have different numbers.

I wish to transfer calls for each number to a different extension!

I am a little bit familiar with freepbx but not at all with asterisk syntax!

Could somebody could help me on configuring that?

Many thanks,

Have you tried the ‘inbound routes’ module?

I do did it. But in the module interface we can filter on who is calling number not the called number.

Did I forget something?

Many thanks,


The called number is the DID.

If the provider is not sending DNIS digits in the called number you will have to resort to dial plan tricks in extensions_custom.conf. Basically you will build a custom context for each trunk, create a pseudo DID info then goto the FreePBX from-trunk context.

If these are ZAP/DAHDI trunks you can use the ZAP DID module to assign the pseudo DID’s.

Do you want trunk “a” to go to ext “a”,
trunk “b” to go to ext “b”, and trunk
"c" to go to extension “c”?


I would like to be able to link a number to a specific extension.

I will try SkykingOH solution, based on DID, then give you feed back.

Many thanks for your answers.


Hi guys,

Many thanks for your support.

SkykingOH is right: in In “Inbound Routes” section DID is the the number that somebody is trying to join.

But, I am using ippi SIP provider (it gives a free telephone number). ippi doesn’t send the DID. The solution is to specify a DID in “Register String” field when defining the trunk settings. The format is login:[email protected]/DID. DID could be chosen whatever then could be used in filtering incoming calls.

I solved the issue thanks to

Thanks again,


Hello everybody,
I try to do the same but I have only one trunk. So I can’t use DID.
I try to use CID but it doesn’t work.
Tell me if you have an idea…
Thank you


Hi Kris,

you have one trunk. and one extension?! on what would you like to route calls?



I too have the same problem, but I have a slightly different behavior. I do not have voice mail enabled. If I have the Inbound Routes set to one extension, I see that extension in the log as having answered the call. If I send the call directly to voice mail in the Inbound Routes, I see vml(101) or something similar in the log. If I put both extensions in a Ring Group, I see an ‘s’ in the log…

I wonder if it has something to do with contexts…

Still, any help from someone who knows the answer would be greatly appreciated.

panasonic telephone system northampton