Lesson #6: In the VoIP Wild West, don't believe every flashing sign that you see or every headline that you read. But rest assured, the Federal Trade Commission will be coming to your rescue ... some day.

And, yes, this is the sixth article in our Asterisk@Home series, and we will show you how to save some money on your current phone bills using Asterisk® Dial Plans, but maybe not quite millions. Everything in this article applies to anyone using Asterisk@Home or a pure Asterisk® PBX with the Asterisk Management Portal (AMP). Read the first five parts (I, II, III, IV, and V), and then you'll be ready to continue on here.

Perhaps the greatest feature of Asterisk@Home is the ease with which you can automatically route outgoing calls based upon the number dialed. And you can do it with or without dialing prefixes such as dialing 8 or 9, and then a 1, and then an area code, and then a phone number. You can use this dialing plan intelligence to route specific types of calls to different VoIP providers thereby taking advantage of cost savings offered by the different providers. For example, Voxee.com has a 1.1¢ per minute rate for calls within the United States with 6 second billing increments. And Free World Dialup (FWD) has free outgoing calls to 800 numbers in the United States. In addition to worldwide calling plans, BroadVoice also has a $9.95 in-state residential calling plan that hopefully will prove to be less controversial than their worldwide plans. It provides unlimited (sort of) in-state calling. The "sort of" is a warning that BroadVoice recently inserted an asterisk (Unlimited*) after all of their so-called Unlimited Dialing Plans despite their continuing ads to the contrary (inset). In the fine print, BroadVoice indicates that they now can retroactively determine that you are not using the plans as they intended them to be used. It's still a bit of a mystery as to what the BroadVoice formula is; however, you are forewarned to be prepared for a legal battle if you exceed their undisclosed calling thresholds. When your international calling gets into the thousands (not billions) of minutes, expect to be converted to a business plan where you'll be billed by the minute at prevailing rates.

Voxilla ad for BroadVoiceHere's the actual text of their Terms and Conditions. On the Voxilla forums, some customers report being "converted" to business accounts merely for calling their girlfriends too frequently. Compare that conduct to the ad now running on Voxilla (see inset) and judge for yourself. Suffice it to say, if you take BroadVoice's bait and attempt to use a billion minutes, you should fully expect a bill for millions of dollars rather than the $19.95 advertised price. Bottom Line: If you choose BroadVoice, protect yourself after signing up by switching to a prepaid debit card with no more than a three-month cash balance: $66.50.

You agree that if BroadVoice determines in its sole discretion that you have used the Service, and/or anyone else has used the Service for any activities and purposes prohibited by this section it may immediately charge you BroadVoice's higher rates for its Business service for all periods, including past periods, in which you use, or used, the Service for such prohibited activities together with a US$100.00 administrative fee for same, and that BroadVoice may immediately charge such amounts on your credit card.

The AMP Approach to Dialing Plans. There are, of course, about A Billion ways to set up Asterisk dialing plans, too. We'll provide one approach that works. When we're finished, you'll have a VoIP dial plan that provides toll-free calling to millions of phone numbers, free calling to anyone in your state, and penny-a-minute long distance calls within the United States with billing increments of six seconds. The total monthly cost is $9.95 plus however many penny-a-minute U.S. long distance calls you make. International savings are equally remarkable. Suffice it to say, you can call Paris, London, Hong Kong, and Tokyo for less than 2¢ a minute with numerous VoIP providers. Check the Voxilla forums for the best current deals. You, of course, can take what you learn here today and embellish these dial plans to meet your unique circumstances. But, we're getting ahead of ourselves. First, you need to know a bit about how Asterisk@Home and especially the Asterisk Management Portal (AMP) process outgoing calls. It's quite different than the pure Asterisk way of doing things so, if you plan to use AMP or Asterisk@Home which uses AMP, learn the AMP way of doing things. It's very powerful and downright easy once you get the hang of it. The only problem is that no one ever bothered to write down HOW ... until NOW!

When you dial a number, AMP compares the dialed number against the Dial Patterns you've set up in your AMP->Setup->Outbound Routing rules. When AMP finds the first matching dial pattern in any Route (going down the list of routes from top to bottom), it then looks there to see what your first Trunk Sequence priority is and applies the Outgoing Dial Rules for that trunk. You set these dial rules in AMP->Setup->Trunks by editing your Trunk configurations. The important point is that the Dial Pattern in your Outbound Routing rule gets processed first, and then the Dial Rules for the Trunk that will actually do the dialing are processed. If this Trunk isn't available for some reason, Asterisk repeats the process using your second Trunk Sequence priority, and so forth until all of the Trunk Sequences are exhausted or the call is successfully dialed. Let's walk through a good example which uses these configurations so you can see how to put one together and what goes where. You'll note that this sequence is exactly backwards from the way you configure new VoIP providers using AMP, i.e. you first set up the trunk and then the outbound rule to support the trunk. As unintuitive as it may appear, it really works quite well ... if you first sit down with a pencil and figure out what you're trying to do. It turns out that's pretty good advice for most programming tasks.

Since we know that FWD provides free outbound dialing for toll-free (800 number) calls, let's use FWD as our top Trunk Sequence priority for placing outbound 800 calls. You can't beat free! We'll assume you've already set up your free FWD account. If not, go here first. Now we want to create a FWD trunk entry using AMP->Setup->Trunks->Add IAX2 Trunk. IAX2 is the native protocol that Asterisk speaks so use it whenever you can to eliminate pesky NAT problems. Just be sure UDP port 4569 on your firewall is redirected to the internal IP address of your Asterisk server. Now back to AMP. In the General Settings, plug in a Caller ID entry, e.g. "DOE JOHN <695695>" where John Doe is your name and 695695 is your FWD number. FWD expects 800 number calls to be in the following format: *18002221212, but that isn't really the way you dial them since there isn't an asterisk on your phone. In the Outgoing Dial Rules for your FWD trunk, enter the following which tells Asterisk to add an asterisk (*) prefix before dialing 18xx calls or add 1 plus an asterisk (*) before dialing 8xx calls. This way FWD can correctly handle calls whether you dial 18002221212 or 8002221212 on your phone. The main point to remember here is that you use Trunk Dial Rules to reformat a dialed number into something the VoIP provider is expecting to see when the call arrives from your Asterisk server. And typically you use Outbound Dial Patterns to interpret the numbers dialed on a telephone instrument and to route the call accordingly. So here's the code for the Outgoing Dial Rules in your Trunk setup for FWD:


Here's the rest of the code you'll need to make and receive calls using FWD. In the FWD Trunk's Outgoing settings, enter fwd for the Trunk Name, and enter the following for the Peer Details using your callerid, username, and password from FWD registration. WARNING: If you cut and paste code from these articles and the code contains quotation marks (such as below), be sure to replace the WordPress-inserted, front and back quotes with normal quotation marks, or you'll send Asterisk into the ozone.

callerid="DOE JOHN" <695695>

For your FWD Incoming Settings, name your User Context iaxfwd and enter the following for the User Details:


For the Registration String, enter 695695:yourpasswordhere@iax2.fwdnet.net using your actual FWD phone number and password. Now save your settings and click the Red Bar to restart Asterisk.

You'll note in the Incoming Settings above, we're using a special context to manage incoming FWD calls: fwd-in. So we need to add some code to process the incoming FWD calls at the bottom of the extensions_custom.conf file. Do that now before you forget it. Don't forget to plug in your own FWD phone number in each line below and then save your file by clicking the Update button. Here's the code to cut and paste:

exten => 695695,1,NoOp(Incoming call for FWD #695695)
exten => 695695,2,Goto(from-internal-custom,111,1)
exten => 695695,3,Hangup

The above code will assure that your incoming FWD calls are processed by the autoattendant we built last week just like your other incoming calls.

Now we're ready to add an Outbound Route for our toll-free calls. Choose AMP->Setup->Outbound Routing. In the Add Route screen, name your new route TollFree. For Dial Patterns, enter the following:


The above code covers all of the existing and planned toll-free area codes in the United States and will be triggered whenever you dial 1 and a matching 8XX area code or just 8XX and a 7-digit number. For the primary Trunk Sequence, choose IAX2/fwd. If you also have an SPA-3000 connected to a PSTN (POTS) line, click add and choose SIP/pstn for the second Trunk Sequence. Click Submit Changes to add the new Outbound Route. Use the Up arrow beside the TollFree Outbound Route to move it up your list of routes so that it is just above all of your other long distance routes. Otherwise, these calls would be processed by the first matching long distance route which would mean you'd have to pay for the call with most VoIP providers. Now click the red bar to restart Asterisk. Note that 10-digit 800 calls (i.e. without a 1) using your PSTN line will fail unless you add 1+NXXNXXXXXX to the Outgoing Dial Rules for your SIP/pstn Trunk. Once you get all the changes entered, make a test call to an 800 number after starting the Asterisk Command Line Interface (CLI) which we covered in the last article. Your output on the CLI screen should look something like the following. You'll note that the highlighted text shows the call was placed using the proper Outbound Trunk: IAX2/fwd.

-- Executing Dial("SIP/204-4c88", "IAX2/fwd/*18005551212") in new stack
-- Called fwd/*18005551212
-- Call accepted by (format ulaw)
-- Format for call is ulaw

AsteriskImplementing Prefix Dialing. There's one more Dial Plan concept you need to get under your belt, and we can demonstrate it by designing an Outbound Route to actually place calls to others with FWD phone numbers. Then, for your homework, we'll leave it to you to design Dial Plans that allow you to place calls to other VoIP providers' customers with whom FWD has peering agreements. There's a long list of them here, and all of these calls are absolutely FREE to anywhere in the world. Another one that's not in the list is using FWD to call BroadVoice numbers: **282 + Area Code + Number. And you also can call FWD numbers from BroadVoice but there may be a charge depending upon your plan: 011+0+393+FWDnumber. Post a comment with a correct dial plan that provides access to all the peering agreement customers' numbers, and you may or may not (more likely) win a prize. We'll only publish correct answers so don't worry about being embarrassed by an incorrect suggestion.

Now, for the missing piece, we need another FWD dial plan that let's you force calls to go out through your FWD trunk. This comes in handy for other providers as well. For example, you might want to dial an 8 prefix to force a call to be sent out to Voxee or 9 to force a call to be sent out through your PSTN (home phone) line. We use 393 (FWD spelled with the phone keys) as a prefix to place FWD calls. All of their numbers have either 5 or 6 digits so the numbers you'd dial would be 393-12345 or 393-123456. What we want the Outbound Route to do is strip off the 393 and then send the call along to our IAX2/fwd trunk for processing. Use AMP->Setup->Outbound Routing and in the Add Route screen, fill in OutFWD as the Route Name. For the Dial Pattern, use 393|XXXX. and don't forget the trailing period. The period tells Asterisk to accept any number (but at least one more) digit following seven initial digits which begin with 393. The 393| expression tells Asterisk to look for a number beginning with 393 and then discard the 393 prefix before sending the call on to the outbound trunk. Note that this dial pattern will avoid interference with local phone numbers beginning with 393 of exactly seven digits ... for those of you that still have local 7-digit dialing. The reason is that you'll have to dial at least 8 digits for this dial plan to be triggered. For the Trunk Sequence, choose IAX2/fwd. Click the Submit Changes button and then move the OutFWD route to the top of your Outbound Routes list. We do this to assure that Asterisk always processes dialed calls beginning with 393 by first examining whether the call can be handled by FWD. Now click the red bar to restart Asterisk. You can try placing a call to yourself by dialing 393 plus your FWD phone number. If you want a test incoming call from elsewhere, go to the Free World Dialup site here and log in with your FWD phone number and password.

Using the samples above, you now should be able to structure a Dial Plan for your Asterisk server which takes maximum advantage of the strong points and cost savings offered by various VoIP providers. For example, our own Asterisk@Home server now has the following Outbound Routes in the following order (from top to bottom):

  • OutFWD ... 393 prefix routes calls to Free World Dialup trunk after stripping 393 prefix
  • OutVoxee ... 9 prefix routes calls to Voxee trunk after stripping 9 prefix
  • OutTeliax ... 8 prefix routes calls to Teliax trunk after stripping 8 prefix
  • OutBroadvoice ... 7 prefix routes calls to BroadVoice trunk after stripping 7 prefix
  • OutPSTN ... 5 prefix routes calls to PSTN trunk after stripping 5 prefix
  • Local ... 404, 678, 770, and 470 prefix routes local Atlanta calls first to BroadVoice trunk and then to PSTN trunk
  • Georgia ... Calls with Georgia area codes are routed first to BroadVoice trunk and then to Voxee trunk and then to Teliax
  • TollFree ... Calls with U.S. toll-free prefix are routed first to FWD trunk and then to PSTN trunk
  • US ... Calls with ten-digit numbers or calls with a 1 prefix and ten additional digits are routed first to Voxee trunk and then to Teliax trunk
  • Server2 ... Calls with a 4 prefix are routed to our secondary Asterisk server for processing
  • The real beauty of structuring a Dial Plan with AMP along the lines that we've shown above is that, when a new VoIP provider comes along with a more cost effective plan down the road, you can add a new trunk for that provider and, in under a minute, adjust the outbound routes of your Asterisk system to take maximum advantage of that provider's strong points. Thereafter, every call placed on your system will use the new Dial Plan without any further training of end-users and without any disruption in service. Try that on your $250,000 Nortel or AT&T system. We'll be talking about the last entry in a future column so stay tuned.

    Disclaimer: Some of what you've read above might be construed by some as legal advice. It's not. It's merely advice learned the hard way through the school of hard knocks. If it saves you some grief or some money, great! But, if you need or want legal advice, hire a lawyer. Remember, you get what you pay for ... and you haven't paid us a dime.

    Finally, we're really sorry if we misled you with our headline. We really didn't mean it. Don't expect to ever hear that from a VoIP provider! And, yes, there are numerous additional articles in this series. You can read all of them by clicking here.

    Be Sociable, Share!

    This article has 6 comments

    1. When adding multiple FWD numbers it looks as though one would have to make a seperate trunk name for each different number? Am I correct in this assumption?

      [WM: Correct.]

    2. Do you happen to know if IAXTEL.COM is defunct? It doesn’t respond to iaxpings. Is there a magical IP or domain name that is needed to set up IAX2 to it? Thanks for the great primer.

    3. I have mastered outbound dialing by prefix dialing. Now, how can one limit a user and or extention to automaticly use a certain trunk?

      [WM: Coming soon. Stay tuned.]

    4. How would you set up an outbound rule in AMP to prepend dialed numbers? For example, I signed up with texiax.com and they want 11 digits for all calls. I would like to be able to dial my local prefixes as 7 digit numbers and have asterisk add the one and the area code. I have searched google to no avail. Any ideas? I am running A@H 2.5.
      Thanks, Tom

      [WM: In your trunk dial rules for Teliax, add an entry like this: 1678+NXXNXXX.]

    5. Thank you so much for the tutorials. I basically had my Asterisk system up in one afternoon (including IVR and some pretty fancy roouting). I want to set up a second server now with a SIP trunk between the two boxes. Do you have such a tutorial or a soup to nuts guide?

      Thanks again

      [WM: Interconnecting two Asterisk systems is on my list along with lots of other long-neglected projects. Here’s a quick IAX solution to get you started.]

    6. I am confused about the georgia scheme. Can you post it? And if anyone submitted the FWD challenge, it would be great to see that too!