Call routing from one asterisk sever to another

Hi
We currently have a setup with three asterisk servers connected with IAX links. One of the servers (serverA) has an ISDN E1 connection to facilitate incoming and outgoing external calls. ServerB and serverC are setup to route any outgoing calls to serverA, where they will be routed down the ISDN line. This was working fine with only one context on each server for external calls and one context for internal calls. The ‘external’ context contained pattern matching for local calls, mobile numbers, and national calls. On serverB and serverC if a SIP phone is assigned the ‘external’ context any calls to external numbers are directed to serverA. serverA then directs the call down the ISDN line.

We have encountered a problem however when introducing more contexts to provide more fine grained regulation of external calls. We have introduced ‘outbound-local’, ‘outbound-mobile’, and ‘outbound-national’ contexts on all three servers. Further contexts have then been introduced to create combinations of contexts providing various ‘permissions’ to phones. For example the context ‘internal-local-mobile’ includes (using ‘include =>’) ‘internal’, ‘outbound-local’, and ‘outbound-mobile’. Therefore, a SIP phone assigned the context ‘internal-local-mobile’ is restricted to only these calls and cannot call national numbers.

On serverA, which has the ISDN connection, when a SIP phone is assigned a context to regulate the type of external calls allowed everything works fine. However, on serverB and serverC when a SIP phone is assigned the ‘internal-local-mobile’ context only local numbers can be called. Calls to internal or mobile numbers have stopped working. Viewing the output at the asterisk console on serverA it can be seen that when a call is made to an external number from a phone attached to serverB or serverC the extension has ‘outbound-local’ appended to it every time. E.g. a mobile number is 07712345678@outbound-local and an internal number is 2123@outbound-local by the time they get from serverB or serverC to serverA. This is despite the pattern matching for mobile numbers (_07XXXXXXXXX) being in the ‘outbound-mobile’ context and the pattern matching for internal numbers (_2XXX) being in the ‘internal’ context.

Could you please advise on the best way forward to resolve this problem

Hi

OK we will work as if its two servers since 3 will be the same.

ServerA has ex1001 and ex1002
serverB has ex1004 and ex1005

1001 and 1004 can call local,national,mobile,international
1002 and 1005 can call local,national

so you create contexts
default (for calling extensions features etc)
out_local
out_national
out_mobile
out_international

then contexts

local
includes out_local,default

national
includes out_local,out_national,default

mobile
includes out_local,out_national,out_mobile,default

international
includes out_local,out_national,out_mobile, out_international,default

so exten 1001 and 1004 have a context of international
and exten 1002 and 1005 have a context of national

These contexts are the same on all switches.

The trunks between swtiches all land in a context of for example tieline_in
which has all contexts included in it. You must be sure that no external trunks can access the tieline_in context as it allowed access. but this shouldnt be an issue

on serverb the outgoing routes are setup for each outgoing context and all sent to servera

This way all call baring is done locally and only valid and allowed calls are sent to the outgoing server. and internal calls.

Ian
www.cyber-cottage.co.uk

Hi, thanks for your reply.

We have done as you advised and set up an incoming context on the external server that allows any calls coming into it to dial out on the external line. Call barring is carried out locally at each server.

However, we are still having the same problem. A call from an internal server to an external number is redirected to the external server. The problem is that the extension has ‘@outbound-local’ appended to it by the time it reaches the external server.

ServerA (external link) Dial plan extract is shown here:

[globals]
ServerB = IAX2/serverB ;Global variable defining the IAX link to serverB
ServerC = IAX2/serverC ;Global variable defining the IAX link to serverC
ExternalCalls = ZAP/g1 ;Global variable defining the external link to make outbound calls

[internal]
;General statements that basically tell asterisk to dial the destination extension and go to voicemail if there is no answer after 30 seconds
exten => _2XXX,1,Verbose(1|Extension ${EXTEN})
exten => _2XXX,n,Dial(SIP/${EXTEN},30)
exten => _2XXX,n,Macro(voicemail) ;The voicemail macro is called to provide an appropriate message. Either a busy message or unavailable message
exten => _2XXX,n,Hangup()

[remote]
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Dial(${ServerB}/${EXTEN})
exten => _1XXX,n,Hangup()
exten => _3XXX,1,NoOp()
exten => _3XXX,n,Dial(${ServerC}/${EXTEN})
exten => _3XXX,n,Hangup()

[outbound-local]
;Outbound calls will be sent down the external link defined by the global variable - ExternalCalls
;The following statements are for people that dial 9 before an external number
exten => _9ZXXXXXX,1,NoOP()
exten => _9ZXXXXXX,n,Dial(${ExternalCalls}/${EXTEN:1}) ;${EXTEN:1} will remove the 9 used for outside lines as it is not actually needed
exten => _9ZXXXXXX,n,Congestion()
exten => _9ZXXXXXX,n,Hangup()
;These statements do not require a 9 to be dialled before an external number
exten => _ZXXXXXX,1,NoOP()
exten => _ZXXXXXX,n,Dial(${ExternalCalls}/${EXTEN})
exten => _ZXXXXXX,n,Congestion()
exten => _ZXXXXXX,n,Hangup()

[outbound-mobile]
;Using the 07XXXXXXXXX pattern as I think all UK mobile numbers start with 07
;The following statements are for people that dial 9 before an external number
exten => _907XXXXXXXXX,1,NoOP()
exten => _907XXXXXXXXX,n,Dial(${ExternalCalls}/${EXTEN:1}) ;${EXTEN:1} will remove the 9 used for outside lines as it is not actually needed
exten => _907XXXXXXXXX,n,Congestion()
exten => _907XXXXXXXXX,n,Hangup()
;These statements do not require a 9 to be dialled before an external number
exten => _07XXXXXXXXX,1,NoOP()
exten => _07XXXXXXXXX,n,Dial(${ExternalCalls}/${EXTEN})
exten => _07XXXXXXXXX,n,Congestion()
exten => _07XXXXXXXXX,n,Hangup()

[outbound-national]
;The following statements are for people that dial 9 before an external number
;The pattern 0[1-2]XXXXXXXXX matches numbers start 01 or 02
exten => _90[1-2]XXXXXXXXX,1,NoOP()
exten => _90[1-2]XXXXXXXXX,n,Dial(${ExternalCalls}/${EXTEN:1}) ;${EXTEN:1} will remove the 9 used for outside lines as it is not actually needed
exten => _90[1-2]XXXXXXXXX,n,Congestion()
exten => _90[1-2]XXXXXXXXX,n,Hangup()

[internal-only]
include => internal
include => remote

[internal-local]
include => internal
include => remote
include => outbound-local

[internal-local-mobile]
include => internal
include => remote
include => outbound-local
include => outbound-mobile

[internal-local-mobile-national]
include => internal
include => remote
include => outbound-local
include => outbound-mobile
include => outbound-national

[incoming_serverB]
include => internal
include => outbound-local
include => outbound-mobile
include => outbound-national

[incoming_serverC]
include => internal

serverB dial plan is shown here:

[globals]
ServerA = IAX2/externalLink ;Global variable defining the IAX link to the externalLink server
ServerC = IAX2/serverC ;Global variable defining the IAX link to serverC

[internal]
;General statements that basically tell asterisk to dial the destination extension and go to voicemail if there is no answer after 30 seconds
exten => _5XXX,1,Verbose(1|Extension ${EXTEN})
exten => _5XXX,n,Dial(SIP/${EXTEN},30)
exten => _5XXX,n,Macro(voicemail) ;The voicemail macro is called to provide an appropriate message. Either a busy message or unavailable message
exten => _5XXX,n,Hangup()

[remote]
exten => _3XXX,1,NoOp()
exten => _3XXX,n,Dial(${ServerC}/${EXTEN})
exten => _3XXX,n,Hangup()
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Dial(${ServerA}/${EXTEN})
exten => _1XXX,n,Hangup

[outbound-local]
;Any outbound local calls will be sent to the external Link server
;The following statements are for people that dial 9 before an external number
exten => _9ZXXXXXX,1,NoOP()
exten => _9ZXXXXXX,n,Dial(${ServerA}/${EXTEN}) ;don’t remove the 9 yet - it will be removed on the externalLink server
exten => _9ZXXXXXX,n,Congestion()
exten => _9ZXXXXXX,n,Hangup()
;These statements do not require a 9 to be dialled before an external number
exten => _ZXXXXXX,1,NoOP()
exten => _ZXXXXXX,n,Dial(${ServerA}/${EXTEN})
exten => _ZXXXXXX,n,Congestion()
exten => _ZXXXXXX,n,Hangup()

[outbound-mobile]
;Using the 07XXXXXXXXX pattern as I think all UK mobile numbers start with 07
;The following statements are for people that dial 9 before an external number
exten => _907XXXXXXXXX,1,NoOP()
exten => _907XXXXXXXXX,n,Dial(${ServerA}/${EXTEN}) ;don’t remove the 9 yet - it will be removed on the externalLink server
exten => _907XXXXXXXXX,n,Congestion()
exten => _907XXXXXXXXX,n,Hangup()
;These statements do not require a 9 to be dialled before an external number
exten => _07XXXXXXXXX,1,NoOP()
exten => _07XXXXXXXXX,n,Dial(${ServerA}/${EXTEN})
exten => _07XXXXXXXXX,n,Congestion()
exten => _07XXXXXXXXX,n,Hangup()

[outbound-national]
;The following statements are for people that dial 9 before an external number
;The pattern 0[1-2]XXXXXXXXX matches numbers start 01 or 02
exten => _90[1-2]XXXXXXXXX,1,NoOP()
exten => _90[1-2]XXXXXXXXX,n,Dial(${ServerA}/${EXTEN}) ;don’t remove the 9 yet - it will be removed on the externalLink server
exten => _90[1-2]XXXXXXXXX,n,Congestion()
exten => _90[1-2]XXXXXXXXX,n,Hangup()
;These statements do not require a 9 to be dialled before an external number
exten => _0[1-2]XXXXXXXXX,1,NoOP()
exten => _0[1-2]XXXXXXXXX,n,Dial(${ServerA}/${EXTEN})
exten => _0[1-2]XXXXXXXXX,n,Congestion()
exten => _0[1-2]XXXXXXXXX,n,Hangup()

[internal-only]
include => internal
include => remote
inlcude => emergency-calls

[internal-local]
include => internal
include => remote
inlcude => emergency-calls
include => outbound-local

[internal-local-mobile]
include => internal
include => remote
inlcude => emergency-calls
include => outbound-local
include => outbound-mobile

[internal-local-mobile-national]
include => internal
include => remote
inlcude => emergency-calls
include => outbound-local
include => outbound-mobile
include => outbound-national

[incoming_serverC]
include => internal

[incoming_serverA]
include => internal