Call Routing based on the station number


Can anyone tell me how i can do a call routing in extensions.conf based on the dialed number and also based on the station that is initiating the call together.

The reason why I need this is because i have several sip accounts at a sip provider. station 301 has the public number +15011301, station 302 has the public number +15011302 and so on.

when station 301 wants to call outside it should use the corresponding sip account from my sip provider.

Right now i use the following routing to route external calls to MYSIPPROVIDER. I allready have several sip accounts configured in sip.conf for the different numbers I have at the sip provider, I just don’t know how I tell asterisk which sip account of the provider it should use for which station.

;This listens for sip end point connected directly to asterisk and
;will listen for traffic that starts with a 9 and send every digit
;after 9 to MYSIPPROVIDER for Asterisk

Regards and thanks in advance

Just to give you a push you could use the conditional Gotoif()
, and make that call be routed based on the extension caller id number
exten => _9.,1,GotoIf($["${CALLERID(num)}" = “301”]?account1) It is just simple dial plan logic

Also, contexts, or “ex-girlfriend logic”.

Note that using several accounts on the same IP address can cause problems. Normally the incoming calls will all seem to be associated with one account. Also the ITSP may not be able to distinguish between outgoing accounts, unless they are the type that require fromuser to be set.