No Inbound Route match on DID only when DID is set to ANY

Hi There,

I have 2 Inbound routes configured to match the exact number. But they won’t work. Inbound routes will only match the 3rd Inbound route where I’ve set the DID to any.

This is what the raw INVITE looks like (sngrep output):
INVITE sip:[email protected]:5060;transport=UDP SIP/2.0
To: sip:[email protected] 83.X.X.X

extensions_additional.conf that was generated by FreePBX:
include => ext-did-0002-custom
exten => fax,1,Goto(${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)})

exten => 31703596733,1,Set(__DIRECTION=INBOUND)
exten => 31703596733,n,Gosub(sub-record-check,s,1(in,${EXTEN},dontcare))
exten => 31703596733,n,Gosub(app-blacklist-check,s,1())
exten => 31703596733,n,Set(__FROM_DID=${EXTEN})
exten => 31703596733,n,Set(CDR(did)=${FROM_DID})
exten => 31703596733,n,ExecIf($[ “${CALLERID(name)}” = “” ] ?Set(CALLERID(name)=${CALLERID(num)}))
exten => 31703596733,n,Set(__MOHCLASS=)
exten => 31703596733,n,Ringing()
exten => 31703596733,n,Set(__REVERSAL_REJECT=FALSE)
exten => 31703596733,n,GotoIf($["${REVERSAL_REJECT}"!=“TRUE”]?post-reverse-charge)
exten => 31703596733,n,GotoIf($["${CHANNEL(reversecharge)}"=“1”]?macro-hangupcall)
exten => 31703596733,n(post-reverse-charge),Noop()
exten => 31703596733,n,Set(__CALLINGNAMEPRES_SV=${CALLERID(name-pres)})
exten => 31703596733,n,Set(__CALLINGNUMPRES_SV=${CALLERID(num-pres)})
exten => 31703596733,n,Set(CALLERID(name-pres)=allowed_not_screened)
exten => 31703596733,n,Set(CALLERID(num-pres)=allowed_not_screened)
exten => 31703596733,n(did-cid-hook),Noop(CallerID Entry Point)
exten => 31703596733,n,Macro(prepend-cid,KiteCare)
exten => 31703596733,n(dest-ext),Goto(timeconditions,2,1)

;–== end of [ext-did-0002] ==–;

Any idea what goes wrong?

Regards, Paul

Hey Paul,

Best bet, remove any inbound routes EXCEPT THE CATCH ALL.

Then I have found in the logs it says something like
"concider setting up an inbound route", when you get an incoming call.

That should give the details to apply a new route.
But it is a long time since I have seen the message so I forget the exact content.


Could it have something to do with FreePBX not looking at the FROM field but to the INVITE URI? In the INVITE my ISP sets the phone part to “sip:[email protected]”, instead of “sip:[email protected]

Here’s the debug output from Asterisk CLI:
– Executing [[email protected]:4] ExecIf(“PJSIP/Redworks SIP Trunk-0000022f”, “1?Set(__FROM_DID=s)”) in new stack

It is difficult from such a small one line log.

This is from a quick test call just now
This is a log from my SIP trunk.
Big chunks missing to save you scrolling down but no mention of the word from-pstn.
How do you stop the line wrap on this forum.?

Executing [[email protected]:1] Set(“SIP/mytrunkname-00000343”, “__DIRECTION=INBOUND”)
Executing [[email protected]:2] Gosub(“SIP/mytrunkname-00000343”, “sub-record-check,s,1(in,0207123456,yes)”)
Executing [[email protected]:1] GotoIf(“SIP/mytrunkname-00000343”, “0?initialized”)
Executing [[email protected]:3] Gosub(“SIP/mytrunkname-00000343”, “cidlookup,cidlookup_11,1()”)
Executing [[email protected]:2] Set(“SIP/mytrunkname-00000343”, “CALLERID(name)=My Number”)
Executing [[email protected]:5] Set(“SIP/mytrunkname-00000343”, “__FROM_DID=0207123456”)
app_dial.c: – SIP/myextension-00000345 is ringing
app_macro.c: == Spawn extension (macro-dial, s, 7) exited non-zero on ‘SIP/mytrunkname-00000343’ in macro 'dial’
pbx.c: == Spawn extension (ext-group, 6000, 11) exited non-zero on 'SIP/mytrunkname-00000343’
pbx.c: – Executing [[email protected]:1] Macro(“SIP/mytrunkname-00000343”, “hangupcall,”)
pbx.c: – Executing [[email protected]:2] GotoIf(“SIP/mytrunkname-00000343”, “1?theend”)
pbx.c: – Goto (macro-hangupcall,s,4)
pbx.c: – Executing [[email protected]:4] Hangup(“SIP/mytrunkname-00000343”, “”)
app_macro.c: == Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘SIP/mytrunkname-00000343’ in macro 'hangupcall’
pbx.c: == Spawn extension (ext-group, h, 1) exited non-zero on ‘SIP/mytrunkname-00000343’

May still be a config issue unless I am reading the wrong stuff.
Then I see that “PJSIP” that always scares me.