[asterisk-users] Outbound DID: in sip.conf or dialplan or db?

Lutgring, Sam LutgrinS at calhounisd.org
Tue Mar 27 06:51:17 CDT 2012

I have done this successfully in 2 ways depending on your requirements.  Usually, I just set the callerid number right in the SIP, this is the easiest and cleanest in my opinion.  Worth mentioning that I always set the callerid in the SIP regardless, this way I know that internal calls, trunk calls, whatever are clean when it rings on any phone (including internal).  In this case my DID number (block of 100) are easily mapped to my extensions (forward planning during setup) because the extension is the last 4 digits of the DID.  This way in the default context I can say exten => _12345XX,1,Goto(default,${EXTEN:3},1) where the extension would be 45XX.

The second way that I have done this is by using the Asterisk internal database (no API or outside DB to worry about).  Then just simply do a DB lookup for the proper callerid before routing the call out.  Where I have had to use this is when multiple phones are grouped (multiple groups) to share a DID number for their callerid.

Sam Lutgring
Director of Informational Technology Services
Calhoun Intermediate school district
lutgrins at calhounisd.org<mailto:lutgrins at calhounisd.org>

From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Roland
Sent: Tuesday, March 27, 2012 4:59 AM
To: asterisk-users at lists.digium.com
Subject: [asterisk-users] Outbound DID: in sip.conf or dialplan or db?

I am setting up my dialplan with quite some outbound numbers. We have a block of 100 DID's, for which some of them will go direct to specific phones. I am struggling how to solve this, so I am searching for a little advice. These are my concerns.

I could set the DID in the sip.conf using something like:

callerid="137-Roland" <31229253137>

137 would be my extention number here.

I think the downside of this is, that I should configure this for each SIP account. I could specify a default callerid, which our main DID, in a template, but then people will see this general ID when I call internal extentions as well. This way the receiver cannot see my extention number.

Other solution would be to specify my DID in the dailplan. I tried this solution, which works:

exten => _00Z.,1,NoOp(Call Received from ${CALLERID(num)} to ${EXTEN:1})
exten => _00Z./Jeroen_S,2,Set(CALLERID(num)=31229700210)
exten => _00Z./Roland_odA,2,Set(CALLERID(num)=31852013900)
exten => _00Z./Schoolshopper,2,Set(CALLERID(num)=31852013900)
exten => _00Z.,2,Set(CALLERID(num)=31229700203)
  same => n,GotoIf($[${CALLERID(num)}=31852013900]?otconnect:voys)
  same => n(otconnect),Set(OUT=999210485)
  same => n,Goto(dodial)
  same => n(voys),Set(OUT=143810001)
  same => n(dodial),Dial(SIP/${EXTEN:1}@${OUT})

Upside is that I can be more specific in routing. The same handset could have different DID's, but I think usually the DID is bound to a SIP account. So I would probably create a second SIP account if a user needs an extra DID anyways.

The downside in my opinion is that my Dialplan will be filled with around 30 extra lines with account specific stuff. I would rather keep my dialplan code clean. Also when I would have more patterns that can be matched, I have to specify them for this pattern as well. That would already take around 60 lines of extra code.

I have considered an AGI call to fetch the data from a database. But wouldn't this be a higher risk? When the database fails or is too slow, it will not work? I would rather use mysql than the asterisk db, because i can manage mysql easy with phpmyadmin.

Any suggestions would  be appreciated! Am I missing any options here?

This email is intended only for the use of the addressee(s) named herein. It may contain legally privileged and confidential information. If you are not the intended recipient, or an authorized representative of the intended recipient, you are hereby notified that any review, copying or distribution of this email and its attachments, if any, is strictly prohibited. If you have received this email in error, please immediately notify the sender by return email and delete this email from your system. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120327/8a2af194/attachment.htm>

More information about the asterisk-users mailing list