How to select outgoing sip based on extension number

Hi there,

What I am trying to do is to make one of the phones on our network use a different sip account when making outgoing calls.

I have two accounts registered in sip.conf:
register => 0000000:secret@provider.com/main_trunk_in

register => 0000001:secret@provider.com/other_in

so that calls to the second phone number go to an individual phone

The outgoing sip settings are below:

[outgoingsip]
qualify=3000
type=friend
host=provider.com
username=0000000
fromuser=0000000
secret=secret
context=incoming
dtmfmode=rfc2833
disallow=all
allow=gsm
allow=alaw
allow=ulaw
allow=g729
nat=yes
canreinvite=no
insecure=invite,port
sendrpid=yes
trustrpid=no
fromdomain=provider.com

[outgoingsip_2]
qualify=3000
type=friend
host=provider.com
username=0000001
fromuser=0000001
secret=secret
context=incoming
dtmfmode=rfc2833
disallow=all
allow=gsm
allow=alaw
allow=ulaw
allow=g729
nat=yes
canreinvite=no
insecure=invite,port
sendrpid=yes
trustrpid=no
fromdomain=provider.com

I want the phone on our extension 400 to use outgoingsip_2 when making calls, but I can’t figure out what to do in extensions.conf to make that happen.

The current outgoing rules in extensions.conf are as follows:
[default]
; Dial Out !
; This is used for outbound calls.

exten => _X.*,1,Dial(SIP/${EXTEN:0}@outgoingsip,60,Tt)
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Playback(on-busy)
exten => s-BUSY,2,Hangup
exten => s-CONGESTION,1,Playback(connection-failed)
exten => s-CONGESTION,2,Hangup
exten => s-INCOMPLETE,1,Playback(connection-failed)
exten => s-INCOMPLETE,2,Hangup
exten => t,1,Playback(connection-timed-out)
exten => t,n,Hangup()

Any help would be much appreciated.

Thanks.

Your subject and body are asking for different things. To do what you ask for in the subject, use explicit extension number pattern matches, rather than _X.

To do what you ask in the body, but the two device in different contexts, or associate a channel variable with the device, or use ex-girlfriend logic (please google).

Note, this assumes that your ITSP looks at fromuser. If they don’t, they will not be able to distinguish between the two accounts.