Dial Plan Priority

Just thought Id see if someone can clarify how Asterisk Matches it Dial Plan Priorites. I thought it was done a a “most closest match” principle. But it appears not. Basically I have the following

exten => _XXXX,1,Dial(SIP/…)

exten => _8XXX,1,Dial(IAX/…)

Both of these above contexts are accessible from my [internal] context where all the extensions are by using

include => context1
include => context2

Internal exists at the top on the extensions.conf file and context1 and then appear under that (in that order)

I noticed the problem today when i wanted to dial into one of our intersate offices meeting room which is room 600. So i dialled “8600” to go out via the IAX trunk into that meeting room. However it kept tryig to connect my call via the context1 priority which is our the SIP interface, hence my call was failing. "Dial(SIP/600) I strip the first 8 off. It should be going out the IAX trunk Dial(IAX2/600)

I thought that 8600 would match _8XXX betetr than _XXXX… Or does Asterisk look down starting at the top for the best match…

Can anyone shed some light on this for me…


I believe you can get round this by changing the order of context2 and contect1 in context internal:-[internal] include => context2 include => context1
However, if that does not work or is unsuitable, try: -

exten => _[0-789]XXX,1,Dial(SIP/…)

exten => _[8]XXX,1,Dial(IAX/…) [/code]
This will work since it makes the patterns non-overlapping and eliminates the sort order problem. Oh, the [] round the 8 aren’t needed, I just used them for clarity.

Sorry, didn’t really answer the core question. The answer is that * sorts the dialplan into purely ASCII order then matches sequentially any overlapping patterns.

Hence, “XXX” comes after “X.” , etc.

Most of the time this works but sometimes it causes some reversal of logic. So you need to make some entries more specific or get crafty with them making the rules work for you instead of against.

There’s a good explanation here http://www.voip-info.org/wiki/index.php?page=Asterisk+config+extensions.conf+sorting