Incoming Calling Rules - misrouting

Asterisk Build:
Asterisk/1.6.0.6
Asterisk GUI-version : SVN-branch-2.0-r4535

I have two sip accounts with one voip provider. I am finding the incoming routing is failing. I want incoming calls on draytel_1 to route to extension 6002 and draytel_2 to go to 6000 but all calls on either trunk go to 6000.

If I reverse the calling rules, all calls on either trunk go to 6002
Here is my config:

relevant bits from users.conf:

[code][draytel_1]
context = DID_draytel_1
host = draytel.org
username = 8377138
secret = 999999 ;not the real one
trunkname = draytel_1 ; GUI metadata
type = peer
nat = yes
hasiax = no
canreinvite = no
registeriax = no
hassip = yes
registersip = yes
trunkstyle = voip
hasexten = no
fromdomain = draytel.org
insecure = port,invite
fromuser = 8377138
authuser = 8377138
disallow = all
allow = alaw

[draytel_2]
context = DID_draytel_2
host = draytel.org
username = 82318126
type = peer
nat = yes
secret = 9999999 ;not the real one
trunkname = draytel_2 ; GUI metadata
hasiax = no
canreinvite = no
registeriax = no
hassip = yes
registersip = yes
trunkstyle = voip
hasexten = no
fromdomain = draytel.org
fromuser = 82318126
authuser = 82318126
insecure = port,invite
disallow = all
allow = alaw
[/code]

relevant bits from extensions.conf:

[code]

draytel_1 = SIP/draytel_1
; comment - what is this - no equivalent for draytel_2 ???

[DID_draytel_1]
include = DID_draytel_1_timeinterval_247,${timeinterval_247}
include = DID_draytel_1_default
[DID_draytel_1_default]
[DID_draytel_1_timeinterval_247]
exten = s,1,Goto(default,6002,1)

[DID_draytel_2]
include = DID_draytel_2_timeinterval_247,${timeinterval_247}
include = DID_draytel_2_default
[DID_draytel_2_default]
[DID_draytel_2_timeinterval_247]
exten = s,1,Goto(default,6000,1)[/code]

Interestingly, I also have another two accounts with another voip provider (voipfone) and I get identical behaviour within the 2 trunks for that provider. These trunks are mapped to ext 6001 and 6004 and always route to 6004. (this was in fact the original example of this behaviour; I added the Draytel accounts later)

So I can reliably call extension 6000 by dialling one of the draytel numbers and can call 6004 by dialling one of the voipfone numbers, but can’t get to 6001 or 6002 at all.

Looking like a bug, but I can’t be the only user to have come across this problem. Any thoughts would be welcome…

Yes, it’s a problem I found too, I just use the same context for all the accounts from the same provider, then in this context I check the number called and use gotoif to go in a different context based on the called number.

Hope this helps.

Cheers.

Marco Bruni
www.marcobruni.net

Marco,

Thanks for the prompt reply.

I’m still a be new to * - I would greatly appreciate a code example to show what I need.

Thanks,

richard

I had the same problem. It seems to occur when two accounts are registered with the same server, or at least the same IP address. As Marco says, you need to use the same context for both accounts. Something like:

Sip.conf:

[draytel_1]
context = DID_draytel
host = draytel.org
username = 8377138

[draytel_2]
context = DID_draytel
host = draytel.org
username = 82318126

And in extensions.conf, the context:

[DID_draytel]

exten = xxx,1,Verbose((1,Incoming on DID_draytel 1)
exten = xxx,n,Dial(…

exten = yyy,1,Verbose((1,Incoming on DID_draytel 2)
exten = yyy,n,Dial(…

Replacing xxx and yyy by whatever extensions are called by the incoming calls.

Regards
Ian

Thanks Ian

Here’s another solution - works for me. In my case the extension to use is unknown at the start of the code.

extensions.conf:

[code][DID_draytel]
include = DID_draytel_1_timeinterval_247,${timeinterval_247}
include = DID_draytel_1_default

[DID_draytel_1_default]
[DID_draytel_1_timeinterval_247]
exten => s,1,Set(Var_TO=${SIP_HEADER(TO)})
exten => s,2,GotoIf($["${Var_TO}" = “sip:8377138@draytel.org”]?extension1,s,1:3) ; Caller has dialled 01335 xxxxxx
exten => s,3,GotoIf($["${Var_TO}" = “sip:82318126@draytel.org”]?extension2,s,1:4) ;Caller has dialled 020 xxxx xxxx
exten = s,4,SayPhonetic(${SIP_HEADER(to)})
exten => h,5,Macro(hangupcall)

[extension1]
exten = s,1,Goto(default,6002,1)

[extension2]
exten = s,1,Goto(default,6000,1)

[/code]

The only slight problem is that whereas for Draytel Var_TO gives this:

sip:8377138@draytel.org

For voipfone I get this:

sip:30128993*200@195.189.173.10

  • so I get the domain for draytel but the ip for voipfone. The concern is that the ip might not remain static over time. I couldn’t see any difference in the entries in users.conf to account for this.

In the example above, if there is no match then step 4 will speak the value of Var_TO to help with debugging (Not what the incoming caller will be expecting but I hope it will never be needed…)

richard

Why? Aren’t the two dialed numbers 8377138 and 82318126? If you have accounts with a SIP provider, they should give you a unique number for each account that will be dialed on incoming calls.

Ian

Ah!

My misunderstanding - I had assumed differently. I’m still very new to * - less than 7 days experience…

I’ll take another look - your solution will be simpler and more reliable.

richard