SOLVED Callcentric incoming DID routing SOLVED

hivemind

New Member
Joined
Jul 14, 2009
Messages
6
Reaction score
0
I've been :banghead: for weeks trying to solve this one.
I have two callcentric accounts on the same PBX, and have 4 DIDs among them. It's taken me this long of trial, error and head-banging to fix it.

To get DID routing on callcentric working:
1)
Create a custom context in /etc/asterisk/extensions_custom.conf
replace the 1777XXXXX... with your Callcentric account number:
Code:
[custom-get-did]
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($["${DID}"<>"1777XXXXXXX"]?from-sip-external,${DID},1)
exten => s,n,NoOp(Processing  Account ${DID})
exten => s,n,Set(MYVAR=${SIP_HEADER(TO):5})
exten => s,n,NoOp(Actual DID from SIP Header is ${MYVAR})
exten => s,n,Set(DID=${MYVAR:0:11})
exten => s,n,Goto(from-trunk,${DID},1)
exten => h,1,Macro(hangupcall)
2)
In /etc/asterisk/sip_custom.conf
change:
Code:
context=from-trunk
to:
Code:
context=custom-get-did
3)
In FreePBX, Create your inbound routes for each DID.
Remember that Callcentric treats all US numbers as 11 digits (1+area+number), so your DID must be "1XXXXXXXXXX"

4)
In FreePBX, change the context for each trunk to "custom-get-did"

5)
Reload asterisk

6) Test

This works under the latest PiaF as of this writing :)
 

vcallaway

Guru
Joined
May 6, 2008
Messages
170
Reaction score
2
The biggest issue I've had with callcentric is consistency. They don't always send the same header.

After you have taken a weeks worth of calls let us know.
 

psychoboy

New Member
Joined
Jan 27, 2008
Messages
21
Reaction score
0
Remember that Callcentric treats all US numbers as 11 digits (1+area+number), so your DID must be "1XXXXXXXXXX"

I kind of wish that all providers would treat North American (US & CA) that way, or at least give the option. It is consistent, considering that is the country code?
 

ksDevGuy

Guru
Joined
Oct 18, 2007
Messages
102
Reaction score
11
Here is another way to implement CallCentric DID's correctly/reliably as it integrates CallCentrics incomplete suggested code with the default FreePBX [from-sip-external] context code, in a manner that still allows "Allow Anonymous SIP" functionality from admin as well as the important feature to let the CallCentric trunk through without having to enable "Allow Anonymous SIP" which adds another possible security risk.

extensions_custom.conf
==================
[from-sip-external-custom]
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)
; CallCentric Check
exten => s,1,GotoIf($["${DID}"="1777yournum"]?callcentric)
; Regular Check
exten => s,n,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?checklang:noanonymous)
; CallCentric DID Code
exten => s,n(callcentric),Set(Var_FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "ss.callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "66.193.176.35"]?callcentric-next:checklang)
exten => s,n(callcentric-next),Set(Var_TO_DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => s,n,GotoIF($["${Var_TO_DID}" = ""]?checklang)
exten => s,n,Set(DID=${Var_TO_DID})
; Regular script continues
exten => s,n(checklang),GotoIf($["${SIPLANG}"!=""]?setlanguage:from-trunk,${DID},1)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
exten => s,n,Goto(from-trunk,${DID},1)
exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
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

sip_custom.conf
============
; Callcentric Entries
context=from-sip-external-custom
srvlookup=yes
session-timers=refuse
session-expires=180
session-minse=90
session-refresher=uas

Remember, to edit the line containing "1777yournum" with your particular CallCentric default DID number and also to include a "1" before the DID entry(ies) in FreePBX's 'Inbound Routes' (or change the code above to edit out the "1" of course!).

Have fun all,

ksDevGuy
 

digital_archivist

New Member
Joined
Jul 10, 2009
Messages
20
Reaction score
0
Bless you, ksDevGuy! I modified your settings for use with DIDforSale - worked like a charm! No more dropped calls for Anonymous CID callers!

Thank you!
 
Joined
Feb 17, 2009
Messages
35
Reaction score
0
I think this will help me??? I have one callcentric account with 2 of my local numbers assigned to it. What I want is separate routing for each local DID. Will this help me make this work?

Thanks!
 
Joined
Oct 26, 2013
Messages
69
Reaction score
23
In later versions of PBX-in-a-Flash I would make the extensions_custom.conf file shown above like this:

extensions_custom.conf
==================
[from-sip-external-custom]
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)
; CallCentric Check
exten => s,1,GotoIf($["${DID}"="1777yournum"]?callcentric)
; Regular Check
exten => s,n,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?checklang:noanonymous)
; CallCentric DID Code
exten => s,n(callcentric),Set(Var_FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "ss.callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "66.193.176.35"]?callcentric-next:checklang)
exten => s,n(callcentric-next),Set(Var_TO_DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => s,n,GotoIF($["${Var_TO_DID}" = ""]?checklang)
exten => s,n,Set(DID=${Var_TO_DID})
; Regular script continues
exten => s,n(checklang),GotoIf($["${SIPLANG}"!=""]?setlanguage:from-trunk,${DID},1)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
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)}") <------------------------- Add this Line ------------------
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

This will log an entry so fail2ban can work if someone is attacking your Asterisk server....
 

Porch

Guru
Joined
Jul 5, 2013
Messages
135
Reaction score
15
Looks like DID checking no longer works. Nothing is ever in ${DID}. I modified the above script to check by the hostname.

[from-sip-external-custom]
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)
; CallCentric Check
exten => s,1(callcentric),Set(Var_FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "ss.callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "66.193.176.35"]?callcentric-next:checklang)
;exten => s,n,GotoIf($["${DID}"="1777xxxxx"]?callcentric) DID checking no longer works.
; Regular Check
exten => s,n,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?checklang:noanonymous)
; CallCentric DID Code
exten => s,n(callcentric-next),Set(Var_TO_DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => s,n,GotoIF($["${Var_TO_DID}" = ""]?checklang)
exten => s,n,Set(DID=${Var_TO_DID})
; Regular script continues
exten => s,n(checklang),GotoIf($["${SIPLANG}"!=""]?setlanguage:from-trunk,${DID},1)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
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​
 

Mango

www.toao.net
Joined
Aug 10, 2013
Messages
46
Reaction score
13
I am still able to check the DID using the following code:

same => n,GotoIf($[${REGEX("1xxxxxxxxxx" ${SIP_HEADER(TO)})}=1]?context,extension,priority)
 

Members online

No members online now.

Forum statistics

Threads
25,802
Messages
167,720
Members
19,232
Latest member
voiplads
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top