VoIP PBX

During the office build I had a few ideas around voice communications;

  1. It would be useful to be able to answer the “house” phone in the office
  2. It would be nice to call the house from the office and vs versa
  3. A “work” landline would be useful
  4. It would be nice to have a desk phone, instead of just my mobile in the office

After a small amount of digging it became apparent that the easiest way to achieve the above would be to install a VoIP PBX, VoIP because the link between the house and the office is going to be fiber and used to pass IP traffic, whilst poking around I came across the RasPBX project which brings you a fully functioning install of Asterisk and FreePBX for the Raspberry Pi and as you know I’m a massive fan of the Raspberry Pi, telephone hardware for use with this kind of setup is cheep and plentiful on eBay.

Due to the amount of information required to set this up I’m going to split it into a number of posts

  • Setting up the PBX, SIP Trunk and SoftPhone (This Post)
  • Connecting Cisco 7940 IP Phones (Still to be written)
  • Connecting a PSTN Line (Still to be written)

So lets get into it…..

This is going to give you a very basic install, I’m 100% certain that what I have achieved in a couple of days of playing around is just the tip of what can be achieved using this very powerful product and there are still many things for me to learn, but that said what I had at the end of this ticked the boxes for what I wanted in a home based system and provided a lot more functionality than I have seen in a number of small business systems over the years I have been working in IT.

Get yourself along to the downloads section at www.raspberry-asterisk.org and obtain the latest version of the image, at the time of writing the latest image was;

  • Raspbian (Debian8 / Jessie)
  • Asterisk 11.20.0
  • FreePBX 12.0.76.2

I used Win32 Disk Imager to burn the image to a  MicroSD, I used an 8GB SanDisk Ultra Class 10 card as that’s what I had kicking around the house, that I was putting in a Pi 2.

There is a getting started guide here that is a help to get you moving in the general direction, but I did find that a number of the links are broken so a little rewriting here and hopefully you will have enough information to get you up and running 😉

Configuring a static IP Address for you RasPBX

Your going to reference the IP in a lot of steps of this guide, so it’s much easier to set it now and know what it is before you have to go back through a bunch of config and change it after the event.

Network configuration is done the standard Debian way. Edit the file /etc/network/interfaces:
nano /etc/network/interfaces

In this file, remove the line

iface eth0 inet dhcp

and insert instead:

iface eth0 inet static
address 192.168.0.50
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1

Replacing the values above with your configuration, restart the networking service by running:

service networking restart

Initial Asterisk setup

Point your browser to the RPi’s hostname or IP address (http://raspbx).

The default login to FreePBX is:
user: admin
password: admin

Its worth noting at this point that a lot (if not all) the changes you “Submit” also require you to “Apply Config” which is red button at the top of the page once it has reloaded after “Submit” has been pressed!

Network Configuration

There are a lot of reported issues regarding single way voice when setting up VoIP PBX’s, and yes I experienced it as well. So lets take a look at the required network configuration next to make the steps of testing go a little smoother.

  1. Login to the FreePBX Admin page as above
  2. Navigate to “Settings” then to  “Astrisk SIP Settings”
  3. Under the “NAT Settings” configure both the “External Address” and the “Local Networks” sections
  4. At the bottom of the page click “Submit”
  5. When the page reloads click “Apply Config” at the top

Port forwarding

I’m going with all the defaults here just to get things up and running, you really need to consider the security of the system and lock things down once you have everything running. There are some very good pointers around security considerations here.

I started of having read an article somewhere (i’ll find the link) by letting all of this lot through to my RasPBX

  • 4569
  • 5004 – 5037
  • 5039 – 5082
  • 10000 – 20000

After I got things up and running I went back and read the security considerations document again and it’s now considerably less ports that are open to the outside world!

Your 1st & 2nd Extension

Out of the box there are no extensions configured on RasPBX, and whats a phone system without extensions?

Again a very basic setup just to get you started and give you the ability to prove things work

  1. Login to the FreePBX Admin page as above
  2. Navigate to “Applications” then to  “Extensions”
  3. From the “Device” drop down select “Generic CHAN SIP Device” and click “Submit”
  4. Under the “Add Extension” heading set the following options
    • In the “User Extension” box enter the extension number you are creating eg. 1001
    • In the “Display Name” box enter the name you want to associate to the extension eg. John Smith
  5. Under the “Device Options” heading set the following options
    • In the “Secret” box enter the password for this extension number (I went for something simple here so it was easy to type, but you will want to change that later to increase security of the system)
  6. Under the “Voicemail” heading set the following options
    • Set the “Status” option to “Enabled”
    • In the “Voicemail Password” box enter the password required to gain access to the voicemail box for this extension (Again I went for something simple here so it was easy to type, but you will want to change that later to increase security of the system)
    • Set the “Required From Same Extension” option to “No”
  7. At the bottom of the page click “Submit”
  8. When the page reloads click “Apply Config” at the top

To enable you to test things your going to want a number to call from your extension so repeat the steps 3 – 8 above to give yourself another extension

Softphone Setup

So now you have some extension numbers on your RasPBX your going to want to connect a phone to the system to make sure it’s working, I did this using a softphone as a) the Cisco 7940’s I had ordered had not arrived yet and b) there is little configuration required in setting up the softphone unlike the Cisco devices as you will find out when I complete the write up.

Being an Apple man a quick look in the app store for “Asterisk” turned up a number of options one of which was “Media5-fone” so I went with that 😉

  1. Connect the device to the same IP Network as the phone system
  2. Start the app up
  3. Tap “Start”
  4. Tap “Preconfigured List”
  5. Scroll down and tap “Asterisk 1.x”
  6. Enter a “Title” so you can identify this connection eg. “Home”
  7. Enter one of the extension numbers you created earlier in the “Username” field eg. “1001”
  8. Enter the secret/password for the extension number you are adding in the “Password” field
  9. Enter the IP Address of the RasPBX in the “Address” filed
  10. Tap “Done”

If all is completed you wont get an error message at this point 🙂 if you do go you can check the settings by

  1. Tap “More” at the bottom right of the screen
  2. Tap “Configure SIP Accounts”
  3. Tap “Home”

Testing

Using the “Dial Pad” option of the software dial the other extension number you created above, if everything is working you should get a message saying “The person at extension xxxx is unavailable” leave a voicemail for this extension and then hang up.

  1. Tap “More” at the bottom right of the screen
  2. Tap “Configure SIP Accounts”
  3. Change the “Username” and “Password” to match the other extension number
  4. Tap “Advanced”
  5. Under the “Voicemail” heading enter “*97” in the “Number” field
  6. Tap “Done”
  7. Tap “Voicemail” and then “Connect to Voicemail”

You should now be connected to the voicemail box of the 2nd extension and be able to listen to the voicemail you left for yourself.

SIP Trunk Setup

There are hundreds of providers out there, many offering free services but as I am based in the UK I went with http://sipgate.co.uk no real reason other than they offered me a free number in the geo region I wanted and there was a small amount of information available on how to set their services up with Asterisk

  1. Login to the FreePBX Admin page as above
  2. Navigate to “Connectivity” then to  “Trunks”
  3. Click “Add SIP (chan_sip) Trunk”
  4. Under the “General Settings” heading set the following options
    • In the “Trunk Name” box enter a name to identify this trunk eg. sipgate
    • In the “Outbound CallerID” box enter the number you chose during you sipgate.co.uk account setup eg. 01234 567890
  5. Under the “Outgoing Settings” heading set the following options
    • In the “Trunk Name” box enter a name to identify this trunk eg. sipgate
    • In the “PEER Details” box enter the following information
    • username=
      type=peer
      secret=
      nat=never
      insecure=very
      host=sipgate.co.uk
      fromuser=
      dtmfmode=rfc2833
      contect=from-trunk
      canreinvite=yes
      authuser=

      Username, fromuser and authuser need to be set to your “SIP-ID” from sipgate

      Secret is your “SIP Credentials” password not the password you setup when creating your account

  6. Under the “Incoming Settings” heading clear the text from box boxes
  7. Under the “Registration String” heading enter the following text string
    • SIP-ID:password@sipgate.co.uk/SIP-ID
  8. At the bottom of the page click “Submit”
  9. When the page reloads click “Apply Config” at the top

Now we have our trunk setup we need to setup routes to enable us to be able to use them

Inbound Route Setup

  1. Navigate to “Connectivity” then to  “Inbound Routes”
  2. Click “Add Incoming Route”
  3. Under the “Add Incoming Route” heading set the following options
    • In the “Description” box enter a name to identify this Route eg. default
  4. Under the “Set Destination” heading set the following options
    • From the 1st dropdown select “Extensions”
    • From the 2nd dropdown select the extension number your softphone is register too
  5. At the bottom of the page click “Submit”
  6. When the page reloads click “Apply Config” at the top

Outbound Route Setup

  1. Navigate to “Connectivity” then to  “Outbound Routes”
  2. Click “Add Route”
  3. Under the “Route Settings” heading set the following options
    • In the “Description” box enter a name to identify this Route eg. default
  4. Under the “Dial Patterns that will use this Route” heading set the following options
    • Set “match pattern” to “X.”
  5. Under the “Trunk Sequence for matched Route” heading set the following options
    • Set “0” to “sipgate” (providing that was the trunk name you setup earlier)
  6. At the bottom of the page click “Submit”
  7. When the page reloads click “Apply Config” at the top

Thats it we are done, now to test it….

Grab a phone that is not the one with your softphone client installed on it and dial the number you selected when setting up you sipgate account, if all is well your softphone should ring 🙂 answer it and make sure you get 2-way audio. The try and call an external number from your softphone, if like me you added no credit to your account you will here a message that tells you there is ) credit on your account!

Enjoy

UM

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *