VoIP HOWTO: Asterisk, SIP, FreePBX, and geekery

This HOWTO’s complexity level is Moderate. You’ll need some experience dealing with networks, a basic grasp of network technology, and the desire to muck around a little bit with configuration.


A year ago, I decided that I wanted to learn VoIP. I’d seen some very interesting examples online and I wanted to try it myself. Those who have tried to do VoIP before have probably noticed the one minor hiccup that comes in tow: nobody wants to teach you how to do it. All people want to do is charge you money to do it for you and provide “support.” This is a pretty good business model, but not very helpful to people like me: the “do-it-yourselfers.”

So as to spare you, the reader, the pain which I experienced gleaning the information from this tutorial from various online forum posts and poorly written outdated howtos, I am going to change that and actually write a post that will get you up and running with a simple VoIP system for your house or small business (or large business, if you’re intrepid).


  • POTS: Plain Old Telephone Service, the kind you have in your house. The phone can be built for very cheap and typically communicates with Pulse dialing (retro style rotary dial) or DTMF, the dissonant tones produced by 3×4 grid of numbers on the dial pad of your phone.
  • PSTN: The Public Switched Telephone Network
  • PBX: Private Branch Exchange, basically the LAN equivalent for VoIP and phone systems.
  • Trunk: a way of transporting multiple phone lines over one cable. Basically, this limits the maximum number of simultaneous calls you can have going between two points. You can also have a “virtual” trunk, which is a trunk that runs over IP. The most common trunk usage is to go between you and your telephone service provider. Importantly, a trunk removes the line to number pairing associated with a regular phone line. Instead, a phone call over a trunk is tagged with either a Direct Inward Dial or a Caller ID number depending on its direction, in or out (see below).
  • FXS or FXO port: An FXS port basically acts as virtual telephone line. It generates a dial tone and the voltage necessary to ring and power the phone. An FXO port, similar to what you have on your modem, is a telephone that terminates in a computer. You use this to route calls over a telephone line from your voip server or gateway.
  • IP Phone: a phone which acts as a computer. Basically it connects to your server over your LAN or the internet and then has a speaker and a microphone on it.
  • DID Number: a “direct inward dial” number is a phone number that, when called, will direct a call over your trunk over the FIRST AVAILABLE channel. In this manner, you can have more DIDs than you can support simultaneous calls and you can support as many simultaneous calls over one DID as you have “channels” in your trunk. When you get a call, it is “tagged” with that DID. With proper DID and CID (Caller ID) filtering, you can direct calls through different Inbound Routes easily.


Before you can start with VoIP, you’re going to need to buy things. If you want a VoIP system, you’ll probably have to buy multiple things.

A BeagleBone Board running Beaglebone Asterisk
A BeagleBone Board running Beaglebone Asterisk
  1. Connection: You’ll need some sort of connection to the outside world if you wish to make public calls, whether this be internet plus VoIP provider or a single POTS line or ISDN digital lines or a fractional or full T1 BRI (a guaranteed rate interface which supports 24 channels). You don’t have to be able to call people off of your PBX, but you may very well want to have this capability.
  2. A server: if you want to coordinate more than a simple Vonage-style phone line, you’ll need to have a server to coordinate the whole process. The hardware you’ll need varies on the complexity of your desired system. The simplest is a good solid x86-based server platform which will allow you to run pre-made distributions and enjoy a little bit more support than alternatives. You can also run a BeagleBone Board which will give you a very low-power (but possibly less reliable) solution. It’s also slower, and will not support as many simultaneous calls as a beefier x86 brethren.
  3. Phones: a phone can be one of two things, either a full computer called an IP Phone or a POTS gateway. The advantage of an IP Phone is advanced features like direct visual voicemail and directory service. Gateways, while they allow you to simply plug the FXS port of your phone into a wall outlet and run your whole house, don’t provide any special features without horsing around. While Cisco phones work with SIP as long as you track down an appropriate firmware, Aastra phones have much better SIP support. The 6757i phones are awesome pieces of equipment. They can also be powered by POE injection from your “server closet.”

*If you choose to get an Analog Telephone Adpater(ATA) to plug your regular phone line into your voip system, be aware that many of these are “locked” and require a special password to access the configuration screen. Without a moderate amount of effort, these are useless to you. Save yourself the trouble and buy either new or used “unlocked” or “NA” units. There are ways to unlock troublesome VoIP adapters if you’re stuck with one.


The almighty name in open source VoIP is Asterisk. It provides basic functionality for call routing between all sorts of different extensions and trunks, and is entirely open source. No matter what, you’ll be using Asterisk in open source VoIP. While it is a great and wondrous beast, many are often turned off because of the level of programming required, specifically the “dialplan” language.

Thankfully, a project called FreePBX was created with the goal of smelting a PHP-MySQL web interface onto the somewhat inscrutable Asterisk. The only problem with FreePBX was that it required a fair amount of manual dependency resolution in order to run the web interface. To top that off, you also had to know how to run a linux server.

So the folks at FreePBX created the FreePBX distro! A full install CD of CentOS, this allows you to run FreePBX on any bare metal x86 machine (or appropriate Virtual Machine) with very little setup cost. Perfect for any mid size or larger install, or whenever you have a server on-site running continuously. It stills runs on Linux though, so you’ll need to know your way around if you want to do anything fancy. Bear in mind that FreePBX “takes over” your webserver, so you’ll want to confine your phone system to a VM if you wish to use your computer for other things.

For those with smaller, less mission-critical needs, you may enjoy RasPBX or Beaglebone-asterisk, which will give you the magic of Asterisk and FreePBX on smaller and cheaper ARM hardware. I do, however, recommend that you run the RasPBX meant for the BeagleBone Board because of three reasons:

  1. BeagleBone has 2GB of internal eMMC memory. The downfall of every PBX with the Pi has been the SD card giving out, and with luck the eMMC will prove more robust.
  2. The BeagleBone sports a more recent version of the ARM architecture capable of running Ubuntu natively as opposed to the bastardized and relatively poorly supported Rasbian.
  3. The BeagleBone, as a result of that improved architecture, faster speed, and two cores, is about twice as fast as the Pi, which will not only increase the number of simultaneous calls you can make but also speed up the web interface by a factor of two (a HUGE improvement over the Pi).

VoIP Trunks

The company I have begun using for VoIP and have never thought twice is FlowRoute. You can read my review on them here. Suffice it to say, however, that they’re the best I’ve seen.

Network Configuration

After installing the software per manufacturer instructions (find the HOWTO on the website and actually follow it…those steps are important) and connecting to the internet, you’re ready to start configuring your system. You should be able to access the web interface by typing in the ip address of your server in a browser on the same LAN. You should probably set the IP of the server to static if you haven’t already done so, which may require adjusting the DHCP address space to leave all addresses below 100 for static use depending on your router configuration. This discussion is for another article, however.

First, if you’re behind NAT, you will have to configure appropriate port forwarding to your server. The necessity varies slightly with the desired functionality of your setup. Forwarding all ports (setting up a DMZ) is convenient, but can lead to security issues. If you are doing this casually, you can use Dynamic DNS to allow you to easily manage your server from anywhere in the world. If you care about security, you best close the ports you don’t need.

Forwarding ports 5600-5610 or so will allow you to register SIP clients remotely. Forwarding your media transfer ports (often 10,000-20,000) will allow you to transfer media with less hiccups. Unfortunately, SIP is not a NAT-aware protocol so NAT between you and your server will get hairy. It works sometimes with iPhone SIP Clients, but often Aastra phones perform poorly. Make sure you’ve properly setup FreePBX as above so that it knows its public IP and internal address space, as this will go a long way to making sure things go smoothly.

Server Configuration

You have to think of the VoIP loop as a path between two points. Basically, you have to get from the telephone on your desk to the PSTN. I’ll outline that path in terms of the FreePBX configuration:

  1. Endpoint/Extension: Your phone has to be registered as an extension under FreePBX. You will also have to make sure your phone has authenticated, meaning it matches the Username with the extension number and the password with the SIP secret. This is the same for any sip client; all that varies is where you enter the password (usually a web gui or config file, or sometimes on the keypad of the display itself). All things relating to the phone (Caller ID, DID number, and Voicemail config) will be setup on this page. You can view registered extensions and SIP status on Reports=>Asterisk Info=>Sip Peers as well as on your device.
  2. Outbound routes: At this point you can call between extensions if you set multiple up. However, when you try to “call out” Asterisk will look for an extension by that number and fail if it doesn’t exist. Outgoing calls have to be “caught” by an outbound route in order to leave your box and go out instead of looking for (and failing to find) an extension or other feature by the same number. You have to add local numbers (NXX-XXXX), fully specified numbers (NXX NXX-XXXX), and long distance numbers (1 NXX NXX-XXXX). You can then direct those numbers to a Trunk. You can also specify prepends and strip out leading digits. For example, if a call comes in to 123-4567, you can prepend your area code (555) to the number to make it properly find the number at your gateway. Remember, your gateway probably doesn’t know which area code to assume as it may be in a different state.
  3. Trunk: This is where you would point your box to FlowRoute. Setup details are available on FlowRoute’s website. Basically populate the fields and hit go. The one issue I ran into is that FlowRoute will REJECT 10 digit calls (this caused me many many hours of pain). That means you MUST have a 1 on the front of your call in order to function. Use the “prepend” function to prepend a 1 onto each 10 digit call that passes through this trunk. Best to do that here and NOT in the outbound route stage in case you ever have another trunk and don’t want it to force long distance. You should also specify a default Caller ID here (and you can also specify one for each extension which will override this if provided). Sip status of the trunk can be verified in SIP Peers as the extensions can.

For incoming calls:

  1. Trunk: As above.
  2. Inbound Route: You can “catch” incoming calls here based on DID number or CID (DID is the number they’re calling, CID is the number they’re calling from). Leaving both blank will catch all other calls.
  3. Extension: You can enter a DID number here which will automatically set an inbound route for that extension for that DID.

Once you have these configured properly, you should be able to make incoming and outgoing calls. You will have to plunk down money to activate your FlowRoute account and also purchase a DID to make incoming calls work.

2013-08-01 19.49.47
Manually configured Aastra 6755i

Advanced Topics

Some of these are modules you have to install. Take a look through the available modules through FreePBX and play around.

End Points

There’s a lot of advanced work that you can do using phones and end points. You can use an Analog Telephone Adapter (ATA) to hook POTS phones into your voip system, which would be more useful in Hotels and whatnot or when you want to provide monthly phone service to your neighborhood.

If you want to configure VoIP phones, there’s a lot of ways to do it. You can manually create the associated configuration files, use an Endpoint manager like Cisco Callmanager (which is for Cisco’s proprietary SCCP protocol), or use Aastra XML scripts.

The cool part of Aastra XML scripts is pure automation and low configuration burden associated with the process. You alone can configure Aastra phones by the Web gui, or by configuration files that are sent via TFTP to the phone. The Aastra XML scripts do something very cool.

When you plug in your phone, it uses mDNS to locate it’s local SIP server serving Aastra XML scripts. It then loads an XML application (which you could also construct yourself, via a long interface document) to the screen. A user logs in, and then it pulls a simple configuration file and maps all the utilities, names, and phone numbers automatically to an appropriately named config file. Basically, you can setup phones by plugging them in and logging in using just the extension number and the voicemail password. Done!

Be aware that the XML scripts are really easy to get going on FreePBX distro but NOT QUITE AS EASY to get going on custom install FreePBX machines or other systems like RasPBX. The .rpm is pre-set to refuse to install on non-FreePBX distro machines, and you’d be on your own getting it running on ARM.

Feature Codes

You can toggle things based on “Feature Codes.” This includes selecting where a call will go and other box features. By routing a call “through” a feature code you can toggle it to voicemail when you pop out of the office for a break or at night when you’re going to bed. You can furthermore map this toggle to a button on a phone. These are called “call flow control.”

Time Conditions

Calls can go different places depending on the time of day. By setting up a time and a condition and routing a call through that time condition, you can have calls diverted based on time of day.

Interactive Voice Receptionists (IVRs)

By creating an IVR, you can play a recording and ask people for “Press 1 for sales, 2 for…” that you’ve heard a million times. You can also enable direct dialing of extensions.


You can direct inward callers via an unspoken IVR option or simply based on Caller ID to a “DISA,” which is basically an internal dial tone (password protect this one:)! You can then call out as if you were internal to the phone system, using two simultaneous channels on your trunk.

Routing between machines

Truly advanced hackers can join two machines together. The recommended method is an IAX trunk. You can setup an “Outbound Route” and an “inter-company” route with a “from-internal” context to allow people in other locations to reach each other over the internet. There are some good resources on this, but it’s quite interesting.


I hope you’ve enjoyed this ridiculously long article on VoIP. Hopefully I have taught you to fish and not given you one. If you would like, you can pay me to answer further questions. Feel free to leave a comment! Enjoy the wonderful world of VoIP.

2013-08-01 19.49.39

5 thoughts on “VoIP HOWTO: Asterisk, SIP, FreePBX, and geekery”

    1. You may be on your own. All the pre-compiled RPMs are for x86 architecture only. If you’d like to dig through, there is pretty extensive documentation.

    1. You’ll need an ATA with a built in FXO port. Several available on Amazon like this one, which includes an FXS port (to which you can connect a phone) and an FXO port (to which you connect your land line). I’ve never actually set up one of these, but I believe you’ll want to set up the FXO port as a trunk. The FXS port will function just like any other IP phone but you’ll require feature codes for functionality like “hold” etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.