Home » Technology » Asterisk CallerID on Steroids: Here’s How

The Most Versatile VoIP Provider: FREE PORTING

Asterisk CallerID on Steroids: Here’s How

We've discussed inbound CallerID with Asterisk® in a previous column, but today we have an incredibly useful outbound CallerID trick. Our special thanks to Matt Avila for bringing it to our attention. As you probably know, most providers don't allow you to adjust the CallerID for your outbound calls. But there are exceptions such as Teliax. The only problem until now has been that using CallerID spoofing required that you pay for outbound calls by the minute. Well, if you're using Asterisk@Home 2.5 or Asterisk 1.2.4, all of that has changed ... with TelaSIP. As long time readers of this column know, in addition to being dirt cheap and honest, TelaSIP has always been our favorite provider, and this neat trick is merely icing on the proverbial cake. You can read all the other reasons why you should switch at this link.

NOTE: This article has been superseded. Continue reading the latest article here.

CallerID spoofing, despite the negative connotation, isn't always a bad thing. Let's cover a few real-world examples. The one we use that has been incredibly helpful is our One Ringy-Dingy free long distance calling service (which is sponsored by TelaSIP incidentally). Try it! Just dial our number in Charleston from a phone with CallerID, wait for a fast busy (so there's no charge for the call), hang up, and you'll promptly receive a return call. After entering the system provided random password, you'll get dialtone to make a free 10-minute long distance call to anywhere in the United States. What we wanted to do with this DISA outbound calling service was to provide the caller's CallerID number to the person being called rather than displaying either our CallerID number or no CallerID. Remember, both the called and calling parties are receiving incoming calls from our Asterisk server using TelaSIP trunks rather than from the actual caller's home or office phone line. That's why the call is free. By the way, we're using GSM compression for these calls so it will give you a good idea of what the call quality is like using a voice compression codec.


A more practical use is for those of you with multiple outbound trunks, multiple DIDs, and multiple users (such as kids), each of whom has (or at least wants) their own extension and outside phone number. With the new TelaSIP service and Asterisk@Home 2.5, you now can automatically customize your CallerID to meet your requirements using the Asterisk Management Portal (AMP). And today we'll show you how. For the truly evil out there, a word of caution. Failure to "send accurate originating calling party telephone number information" on interstate calls may violate the Federal Communications Act. In fact, that is exactly what we use CallerID spoofing to do: to send accurate originating calling party telephone number information, i.e. the true identity of the calling party. If you abuse this or any other service, the feds may very well track you down. And TelaSIP probably feels the same way if you abuse their service. See this article for details. Don't ruin a good thing by being a jerk. You will get caught. Asterisk logs make it incredibly easy to find (and hang) you.

Using AMP to Manage Incoming TelaSIP Calls. Let's start by examining what we want to accomplish. Suppose you have a single VoIP trunk with TelaSIP, but you have three teenagers that love their privacy and would like their own line. With TelaSIP, it's easy. Just order a single VoipXpress Premium account with unlimited U.S. inbound and outbound calling ($15.95) and two additional DID's in your favorite area code ($1.99 a month each), and you're all set. According to some readers, you may need to request that TelaSIP let you manage your own CallerID so you might want to include that in your note when you sign up. If you're feeling like a big spender, order an additional trunk just to use for inbound calls ($5.95) and add your two DID's to that trunk. That gives you two lines and four DIDs in your choice of area code for about the same monthly cost as a single Vonage line with a single DID. When you receive your username and password from TelaSIP, configure the TelaSIP outbound trunk settings in AMP using the example below (with your account name and password obviously) after naming the trunk TelaSIP-gw or TelaSIP-gw2:

disallow=all
allow=gsm
canreinvite=yes
context=telasip-in
dtmfmode=rfc2833
fromuser=youracctname
host=gw4.telasip.com
insecure=very
secret=yourpassword
sendrpid=yes
type=peer
username=youracctname

Leave the Incoming Settings section of AMP blank, and fill in your Register String in this format: youracctname:yourpassword@gw4.telasip.com.

You'll need the fromuser entry above if you're running more than one TelaSIP account on the same Asterisk server so TelaSIP can figure out how to route the call. If you have loads of bandwidth in both directions, delete the first two lines to use an uncompressed codec (ulaw): disallow=all and allow=gsm. All of the CallerID magic depends upon the line which reads sendrpid=yes. This tells TelaSIP that you'll be responsible for setting the CallerID for each outbound call over this trunk.


We could use AMP's DID Configurator to manage the inbound calls, but we've just never quite trusted AMP on this. Can you spell B-U-G-G-Y. Plus, our manual way isn't very hard and it gives you some extra flexibility. So add a new context at the bottom of extensions_custom.conf (AMP->Maintenance->Config Edit->extensions_custom.conf). Replace 8431234567 with the DID number for this line, replace the 201 in SIP/201 with the extension to be dialed for this call, and replace the 201 in 201@default with the voicemail account for this extension. To add a second trunk and extension, just duplicate the seven lines of code in the same context and repeat the drill using the second DID and extension. Save your changes and reload Asterisk. You're supposed to know how to do this by now!

[telasip-in]
exten => 8431234567,1,Answer
exten => 8431234567,2,Wait(1)
exten => 8431234567,3,Background(pls-hold-while-try)
exten => 8431234567,4,NoOp(Incoming call for Suzie on TelaSIP #8431234567)
exten => 8431234567,5,Dial(SIP/201,20,m)
exten => 8431234567,6,VoiceMail(201@default)
exten => 8431234567,7,Hangup

exten => 8431234568,1,Answer
exten => 8431234568,2,Wait(1)
exten => 8431234568,3,Background(pls-hold-while-try)
exten => 8431234568,4,NoOp(Incoming call for Timmy on TelaSIP #8431234568)
exten => 8431234568,5,Dial(SIP/202,20,m)
exten => 8431234568,6,VoiceMail(202@default)
exten => 8431234568,7,Hangup

Suppose you want to add a DID which automatically transfers inbound calls on that number to your cellphone, but you want to preserve the original caller's CallerID so you can see where the incoming call on your cellphone is coming from. Why would you want to do this? Well, it keeps your cellphone number a secret and gives you unlimited flexibility to block calls from creeps. Just search around on Nerd Vittles for the tutorials if you want to get fancy. You'll need two trunks from TelaSIP to make call transfers to your cellphone work. Or just sweet talk Gene into adding a second channel on your original trunk ... for a few cents more. It saves them the headache of maintaining two separate accounts for you. In this case, just adjust the number of channels in your trunk configuration to 2 instead of the original 1 setting.

For the example below, we'll assume you chose not to go the sweet talk route, and that telasip-gw is your inbound trunk with the extra DIDs and telasip-gw2 is your outbound trunk. You don't need extra DIDs for the outbound trunk since we can spoof the CallerID. Just add the code below to your [telasip-in] context using your DID number instead of 8431234569, your cellphone number instead of 6781234567, and whatever Asterisk voicemail box you want to use instead of 203 just in case your cellphone voicemail fails to pick up the call wihin 60 seconds.

exten => 8431234569,1,Answer
exten => 8431234569,2,Wait(1)
exten => 8431234569,3,Background(pls-hold-while-try)
exten => 8431234569,4,NoOp(Incoming call for Billy Bob cell on TelaSIP #8431234569)
exten => 8431234569,5,SetCallerID(${CALLERIDNUM})
exten => 8431234569,6,Dial(sip/6781234567@telasip-gw2,60,m)
exten => 8431234569,7,VoiceMail(203@default)
exten => 8431234569,8,Hangup

Managing Outbound CallerID for Different Extensions. We've resolved how to manage incoming calls with multiple DIDs and users. Now let's tackle the other issue. We want outbound calls from each extension to look like they came from different phone numbers even though we'll be using one outbound trunk to handle all the calls (not at the same time obviously). Of course, if you need simultaneous outbound calls, you can add additional outbound trunks, and we'll show you how to configure the outbound dialing to support it.

One of the great improvements in AMP 1.10.010 which is bundled with Asterisk@Home 2.5 is the ability to manage CallerID for individual extensions. For this to work, leave the CallerID entry in your TelaSIP trunk entries blank. Then, as you create your extensions (201 and 202 in the example above), fill in the CallerID you want to associate with outgoing calls from each extension in the Outbound CID field. If you want this setting to override your default trunk CallerID, be sure to use brackets around the number, e.g. <4041234567>. (Thanks, Matt!) Save your settings and click the Red bar to reload Asterisk. The only trick to this is making sure that your Outbound Routing in AMP is configured to route outgoing calls to your appropriate TelaSIP trunks for placing outgoing calls. If you want to use multiple TelaSIP trunks for outbound calls, then simply add each TelaSIP trunk name in the Trunk Sequence for your outbound route, and Asterisk will go down the list when your first priority trunk is busy. It doesn't get much easier than that.


But what about the cellphone? How do we make outbound calls from our cellphone using the CallerID number from one of the DIDs on the Asterisk system? Well, that's what DISA is for. Just add the following code above the 8431234569 lines in the sample assuming your cellphone number is 6781234567. Why do we require a password for the incoming call when we've specified the number of your cellphone? Because you aren't the only person on the planet that can spoof CallerID numbers. So change the password in line 3 to something VERY SECURE. It's your phone bill!

exten => 8431234569/6781234567,1,Answer
exten => 8431234569/6781234567,2,Wait(1)
exten => 8431234569/6781234567,3,Authenticate(1234)
exten => 8431234569/6781234567,4,DISA(no-password|telasip-out)
exten => 8431234569/6781234567,5,Hangup()

Next add the following code at the very bottom of your extensions_custom.conf file after all of the [telasip-in] code, save your changes, and reload Asterisk.

[telasip-out]
exten => s,1,Background(pls-hold-while-try)
exten => s,2,SetCallerID(8431234569)
exten => s,3,Dial(local/${EXTEN}@from-internal)
exten => s,4,Hangup

Then, to place outbound calls from your cellphone, "Phone Home" to 8431234569 and enter your DISA password. When you get dialtone, key in the number to call in a format that matches your outbound trunk(s) dialplan. When the phone rings at the other end, it will display the CallerID of your home DID trunk. Now wasn't that easy!


Some Recent Nerd Vittles Articles of Interest...


21 Comments

  1. Ward, I use VoipJet for my outbound calls because of the unlimited number of simultaneous calls. How many concurrent calls can you make on TelaSIP?

    [WM: When you pay by the minute, most VoIP providers give you unlimited, simultaneous calls. When you have an all-you-can-eat, fixed price plan, you typically get one call at a time for each trunk you have bought. VoipJet is a good pay-by-the-minute provider with low rates. Another good one is Voxee. We’ve done reviews of a number of providers that all are listed in our 50 Great Halftime Projects for Asterisk.]

  2. Great article, one addition I would like to see though is the ability to use a simultaneous ring strategy that will call both our IP phone and our cell at the same time and/or a call-hunting system that will attempt to ring our IP phone, and fail-over to our cell.

    [WM: That’s what Ring Groups do. Take a look at the Adding Cellphone Extensions section of our AAH 2.5 Tutorial.]

    Overall, I love it. I enjoy the knowledge that you share with the asterisk community, keep up the good work. One thing I noticed in your priorities, it appears that it will announce 2 times before calling my cell, (priorities 3 and 5), shouldn’t it only announce once?

    [WM: Thanks for catching it. I’ll fix it.]

  3. Kaleb, instead of using the Rings Groups Hunt, I created my own using a custom setup in extensions_custom.conf. In my IVR, I state to reach Chris, press 1 and it points to this context. If the user presses # and uses the directory, (which I do not mention in my IVR), it will only ring my extension. The only thing I do not like about the Ring Groups hunt is that you don’t have alot of flexablity with them. The one I created calls my desk phone for 15 seconds, then says please wait while I connect your call and plays music on hold. It will dial my cell phone for 25 seconds and if I don’t answer that it reverts back to my extension voicemail. You may also implement this internally if you place this under [from-internal-custom]

    [from-internal-custom]

    exten => 200,1,dial(sip/200,15) ;find me follow me internal
    exten => 200,2,playback(pls-wait-connect-call)
    exten => 200,3,Setvar(NewCaller=${CALLERIDNUM})
    exten => 200,4,SetCIDNum(0${CALLERIDNUM})
    exten => 200,5,dial(IAX2/voipjet/19999999999,25,m)
    exten => 200,6,SetCIDNum(${NewCaller})
    exten => 200,7,Macro(vm,200)
    exten => 200,8,hangup

    [custom-hunt200]
    exten => 200,1,dial(sip/200,15) ;find me follow me external
    exten => 200,2,playback(pls-wait-connect-call)
    exten => 200,3,Setvar(NewCaller=${CALLERIDNUM})
    exten => 200,4,SetCIDNum(0${CALLERIDNUM})
    exten => 200,5,dial(IAX2/voipjet/19999999999,25,m)
    exten => 200,6,SetCIDNum(${NewCaller})
    exten => 200,7,Macro(vm,200)
    exten => 200,8,hangup

  4. Note that with Telasip (at least in my case) I had to call them to request that I be allowed to provide my own caller ID. (a completely painless process, btw. Cheers for great customer service!)

  5. How can I setup CalledID for a specific extension, but still allow it to preserve the internal extension when making SIP calls? I need different DID CallerID for extensions for outbound calls, but when calling an internal extension it comes up with the DID caller ID. Any ideas?

  6. Ward – Ill be happy to field that latest question – if you would, please send my e-mail to "Chris" and Ill contact him and walk him through it. In a nutshell its all about using the CID and extension names. If you set the "display name" field to your extension NUMBER – internal calls will show that way…. whatever that ID is set to. The "outbound CID" field can be set to override the trunk CID, BUT you MUST be sure to format it as "<xxxxxxx> or <xxxxxxxxxx>" (note that the brackets are REQUIRED. I haven’t been successful in getting a name inserted into that field.

    Also to note, from my experience and understanding the NAME that shows up on an incoming CID lookup is actually from the phone companies records – its NOT being sent with the CID number stuff… so having the name field set to either a name and/or name and extension will NOT affect what is passed to external numbers (outside the PBX).

    Cheers – Matt

  7. Has anyone had any problem with AMP not writing the "outboundcid" to the Asterisk database? Everytime I make a change to the extensions and then hit the red bar I lose all of my outbound CID information in the Asterisk database. I have to go into the asterisk console and issue the following command for all of my extensions: ‘database put AMPUSER/1005 outboundcid "Kevin Doe <4045551212>" After that my outbound CID works great.

  8. I sent email to Telasip requesting that I be allowed to manage my outgoing caller ID from Asterisk. They replied indicating that they removed called ID at their end. I then placed number in the outbound caller ID field for the Telasip trunk. Now when I call pleaple get "Unknown" for the caller ID insted of the number I configured in the trunk settings. Any suggestions?

    [WM: You’ll need Asterisk@Home 2.2 or later, and you need to add sendrpid=yes to the TelaSIP trunk entries. Then set the CallerID. Some have indicated that in AMP you’ll need to enter the CallerID as <6781234567> to get it to work. Good luck.]

  9. Is it possible to change your outbound callerid based on the dialed number?

    ex. We have a Texas number and an Alabama one. When my wife dials any number in Alabama, would it be possible to cause her outbound callerid to be show as our Alabama number?

    [WM: With TelaSIP, it’s easy. We’ll revisit this issue shortly in a full column.]

  10. This site really helped me to sort CallerID stuff we do lot of Mobile roaming cost cutting for our cliens i.e before they leave country they divert their mobile calls to our local no and we then pass the call to their local sim whichever country they are in. I have been trying to set the CallerID to Callee ID and your article solved the problem for me Thanks a Lot.

  11. I am using the PBX at PBXES.com and it is settting the caller ID to pass to my asterisk box, which is performing LCR, and passing along to trunks that support Caller ID. I have made multiple tests however asterisk seems to pass the account name (account that PBXES registers to) as opposed to the individual PBX extension caller ID.

    Anyone know of a fix for this?

  12. I have a question. How do I send a incoming call based on it’s caller ID phone to a ring group? Basically I want to send a number coming from: 6125550000 to ring group number: 2? I also want all other callers to go to a IVR named: menu. Can you help me with this?

  13. I am having a problem where I can set the CID number but not the ID. No matter what name I enter it still comes up as the person who belongs to the number. I’ve tried these formats: John Doe<9876543210> and "John Doe"<9876543210>.

    Also, I have to set the phone number to 10 digits to get it to send.

    How can I correct these two issues? Thank you in advance.

  14. Bill,

    I work for a company that installs telephone systems, and (in the US anyway) the only way I am aware of to spoof the Caller ID where the PSTN (Public Switched Telephone Network) is concerned is through digital PRI trunks. I assume that’s what type of dialtone Telasip is using to place the calls on the PSTN. Trouble is, only Caller ID number can be supplied to the PRI, not name. The PRI dialtone provider will accept the number only and at some point, the number you have supplied will be matched up with the name belonging to that number’s account and this will become the Caller ID. It is not a limitation of Asterisk and is beyond all of our control. Now, I’ll leave it to others more knowledgeable than me to answer whether caller ID name and number can be supplied when the PSTN is not involved (I sure would think so though).

  15. Someone it seems has been making prank calls and using my cell number as the ring back. Is there any way that I can find out who is doing this?

  16. If someone is using your CallerID, then they are most likely using one of these voip server providers that let’s you specify your caller ID. It’s a shame, but there is not too much you can do.

Comments are closed.