Can't get inbound routes to work with a specific DID

Hi guys

I am trying to get inbound routes to work as follows (very simple set up):

If someone calls our UK DID number (02894 XX XX XX) it will dial a certain ring group called UK ring group (with UK employees extensions)

If someone calls our ROI DID number (01 51 XX XX) it will dial a certain ring group called ROI ring group, again with ROI employees.

So I have a UK inbound route with the associated DID number (44 2894 XX XX XX) and an ROI inbound route with the associated DID number (353 151 XX XX). It works when I ring the ROI number, e.g. If i ring 0151 XX XX it works, and if i ring 353 151 XX XX it works! However, if I ring 02894 XX XX or 44 2894 XX XX it won’t work.

I get the following error in the Asterisk logfiles:

538 [2022-06-10 14:45:48] ERROR[27288][C-00000046] pbx_functions.c: Function SIP_HEADER not registered
539 [2022-06-10 14:45:48] VERBOSE[27288][C-00000046] pbx.c: Executing [[email protected]:3] Log(“PJSIP/XXXX_trunk-000000XX”, "WARNING,Friendly Scanner from ") in new stack
540 [2022-06-10 14:45:48] WARNING[27288][C-00000046] Ext. s: Friendly Scanner from

I also see these logs which show the call is hitting the server:

470 Diversion: sip:[email protected];privacy=off;reason=unconditional;counter=1;screen=no
471 P-Called-Party-ID: sip:[email protected]

Not sure why it works for the ROI number but not the UK number?

Also, if i was to change the inbound route to ‘ANY’, then I can call either number, and both will work fine. It seems to be the inbound route that is the problem?

You need inbound route matches for all the forms in which you receive the DID.

Is that located in connectivity->trunks->dial manipulation rules?

I can’t see anything about matching in the Inbound routes section

You can also use an initial context that canonicalises the DID before passing it to from-trunk. However, I believe that the only pre-defined one is for the North American Numbering Plan, and won’t work in Ireland.

It appears that you have separate trunks for the UK and IE numbers. On the UK trunk, the provider is not sending the DDI in the SIP URI. If the UK trunk has only one number, try setting Contact User to 442894XXXX or 02894XXXX, whichever you have as DID Number in your Inbound Route.

If you have (or plan to get) multiple numbers on the same trunk, change the Context for the trunk to from-pstn-toheader and set the DID Number of the Inbound Route to whatever the provider sends, probably 442894XXXXXX.

I misread the logs, and latched onto the DID in the wrong place. In fact, I think the problem here is that the DID is being provided in an unconventional way, namely in the Diversion header, and you may need custom dialplan to parse it out of that, if you can’t get away with using s a as proxy for the UK one.

One other thing is that your log doesn’t start at the beginning of the context. There should be a line for from-pstn,s,1, but your log starts at from-pstn,s,3

(I’m assuming, that as you haven’t shown it, the To header is not useful. Otherwise, there is s standard initial context (from-pstn-toheader) that extracts the DID from the To header.)


vi /etc/asterisk/extensions_custom.conf

create a context for each trunk (picture1) that you will put on each trunk after on the freepbx interface.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.