Just some notes on how to set up a Callcentric trunk in FreePBX and receive incoming calls without the need to create multiple trunks. This overcomes a limitation in Asterisk that is discussed in several other places (use a search engine if you really want to know).
Trunk settings:
When setting up the trunk use the following in the PEER details (change the highlighted parts):
type=peer
secret=password
qualify=yes
insecure=port,invite
host=callcentric.com
fromuser=1777XXXXXXX
fromdomain=callcentric.com
disallowed_methods=UPDATE
disallow=all
directmedia=no
defaultuser=1777XXXXXXX
videosupport=no
context=custom-from-callcentric
allow=ulaw
And don’t forget to use a Register String (replace YYYYYYYYYY with your DID):
1777XXXXXXX:password@callcentric.com/YYYYYYYYYY
EDIT: Instead of using custom-from-callcentric as the context, in recent versions of FreePBX you can use from-pstn-toheader instead, and then skip the next step (the addition of the custom-from-callcentric context to extensions_custom.conf) entirely!
Add context to etc/asterisk/extensions_custom.conf:
In etc/asterisk/extensions_custom.conf add this context:
[custom-from-callcentric]
exten => _X!,1,Noop(Incoming Callcentric call)
exten => _X!,n,Set(CCDID=${CUT(CUT(SIP_HEADER(To),@,1),:,2)})
exten => _X!,n,Set(CDR(did)=${CCDID:1})
exten => _X!,n,Goto(from-pstn,${CCDID:1},1)
exten => h,1,Macro(hangupcall,)
Copy context to extensions_override_freepbx.conf and modify it:
Open etc/asterisk/extensions.conf in a text editor such as nano, and find the [from-sip-external] context. It will probably look like this, or something very close:
;-------------------------------------------------------------------------------
; from-sip-external
;
; This context is the default SIP context unless otherwise changed in the SIP
; Settings module or other sip configuration locations. This context is hit by
; either anonymous SIP calls or mis-configured SIP trunks when the incoming call
; can not be matched with a SIP section.
;
[from-sip-external]
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
exten => s,1,GotoIf($["${SIPLANG}"!=""]?setlanguage:checkanon)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
exten => s,n(checkanon),GotoIf($["${ALLOW_SIP_ANON}"!="yes"]?noanonymous)
exten => s,n,Goto(from-trunk,${DID},1)
exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
exten => s,n,Log(WARNING,"Rejecting unknown SIP connection from ${CHANNEL(recvip)}")
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup
;-------------------------------------------------------------------------------
Copy the entire context into etc/asterisk/extensions_override_freepbx.conf (without changing any other contexts that may already be there) and make the highlighted changes shown below. Don’t forget to replace the line number in the line that ends with “?checklang:noanonymous)” or things may break. EDIT: Replace custom-from-callcentric with from-pstn-toheader if you did not create the custom-from-callcentric context above:
;-------------------------------------------------------------------------------
; from-sip-external
;
; This context is the default SIP context unless otherwise changed in the SIP
; Settings module or other sip configuration locations. This context is hit by
; either anonymous SIP calls or mis-configured SIP trunks when the incoming call
; can not be matched with a SIP section.
;
[from-sip-external]
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
; Next 2 lines required to avoid adding 20 or so additional trunks just to receive CallCentric calls
exten => s,1,Set(FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,n,GotoIf($[${FROM_DOMAIN}=ss.callcentric.com]?custom-from-callcentric,${DID},1)
exten => s,n,GotoIf($["${SIPLANG}"!=""]?setlanguage:checkanon)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
exten => s,n(checkanon),GotoIf($["${ALLOW_SIP_ANON}"!="yes"]?noanonymous)
exten => s,n,Goto(from-trunk,${DID},1)
exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
exten => s,n,Log(WARNING,"Rejecting unknown SIP connection from ${CHANNEL(recvip)}")
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup
;-------------------------------------------------------------------------------
Note that every time you do a FreePBX upgrade you should open etc/asterisk/extensions.conf and make sure that the [from-sip-external] context has not been changed by the FreePBX upgrade. If it has, then you should make sure those changes get copied into the replacement context in etc/asterisk/extensions_override_freepbx.conf.
We’ve seen similar instructions that are more complicated than this (with regard to the added lines in the [from-sip-external] context) but we’ve been using this for a while and have found that it’s all you need – we’ve not seen any incoming Callcentric calls that have failed to be handled properly since we started using this.
Like this:
Like Loading...
Recent Comments