Friday, 05 February 2016 15:55

Asterisk + FreePBX + Raspberry Pi 2 = VoIP Sip Server

Written by 
Rate this item
(9 votes)

Asterisk and FreePBX Raspberry Pi 2 Install

Asterisk with FreePBX installed on a Raspberry Pi 2, gives me a small, VoIP server that I can use for all my telephony needs.

I needed a small footprint, portable VoIP system for some R&D SIP work, and with RasPBX, this solution works out better than I expected.

I ran Freeswitch along with FusonPBX for many years in a virtual machine on a server at home.  Over the years things have changed, and I no longer need to have my server running 24/7. I switched out many of my virtual machines to small form factor PC's or Raspberry Pi's.  Switching my VoIP server to a Raspberry Pi 2 has now given me the portability I wanted, and I can now easily take it from job to job without any hassle.

I desperately wanted to install the new Freeswitch 1.6 onto my Raspberry Pi 2, but after hours of attempting to compile, and searching through forums, I could not get it to work.  Freeswitch 1.6 made some significant changes and requires libraries available in Debian 8- Jessie which is what Raspbian - Jessie  is based on.  Many of the dependencies were not available at which point caused the compile to fail.  It doesn't appear that the Freeswitch team will be porting over 1.6 to the pi any time soon, as they have their hands full at the moment, so for my Raspberry Pi experiments, I move on to Asterisk.

I have never used Asterisk before.  Years ago, when I wanted to play around with VoIP, it seemed that Freeswitch had more to offer, they seemed to be attempting Video support and I seemed to grasp the architecture better on how Freeswitch was structured.  At the time there was a strong community behind both (and continues today), and Asterisk actually seemed a bit more popular, Freeswitch seemed like it was heading in the direction I wanted.  I still plan on upgrading to 1.6 on a virtual machine at a later date, but today I need a small, portable unit, so Asterisk for the win!

UPDATE 20160310: I have successfully compiled Freeswitch 1.7 on a Raspberry Pi 2, I created a guide here: Freeswitch 1.7 + Raspberry Pi 2 = VoIP Sip Server


Things You'll Need

  • Raspberry Pi 2 (with Micro SD card of at least 4GB)
  • SSH Client (terminal window in linux or program like putty)
  • Sip Client (either for your phone or PC) used to test connectivity (3cx, CSipSimple,  etc)


Installing Asterisk and FreePBX

Asterisk, is an open source framework for developing communications applications.  FreePBX is one of the many graphical front ends to configure and administrate asterisk.  There's different options available on how to install either of these two onto your Raspberry Pi 2, but after many hours of failed attempts to get Freeswitch running, I decided to go with an easy option, RasPBX, a full distro with Asterisk and FreePBX already installed.


- Getting the RasPBX distro onto your Micro SD Card

You'll need to download the latest image from, currently of this writing, it is the latest beta version which is recommended for the Raspberry Pi 2.  It comes with Asterisk 11.21.0 and FreePBX 13.0.51 pre-installed.  4GB card is also required.

On a Windows computer, you can use Win32DiskImager and follow my guide here, How-to: Write a Raspberry Pi image to an SD card in Windows , and just substitute the Raspbian image for the RasPBX image, in the instructions.

On a Linux computer, you can follow the steps below

Download the RasPBX image onto your computer (If wget fails to download, I suggest you visit the RasPBX website to find the latest image available), it's a very slow took me close to 2 hours.




Run this while you Insert your Micro SD card

watch 'dmesg | tail -20'

While that command is still running, plug the Micro SD card back in, your looking to find what device it is showing up as (ie: sdb, sdc, sdd, etc)

pi asterisk freepbx install 01

In our example, you can see that the SD card is showing up as sdc, In these examples, we will now refer to our card as sdc (although yours may be sdb, sdd, etc)

Once you see something similar to this screen press Ctrl+c to exit the last command.


Unmount your Micro SD Card (replce sdc in the command below, with what your card is)

for n in /dev/sdc* ; do umount -l $n ; done


Using the command dd, we will write the image you previously had downloaded, directly to your SD card

*Important, be sure to substitute the full path of your RasPBXi image and your SD letter (sd[x]) shown in the example below

sudo dd bs=4M if=<-full-path-of-raspbx-image> of=/dev/<sd-card-location>


sudo dd bs=4M if=raspbx-25-01-2016.img of=/dev/sdc

You will not see any progress as the card is being written, It should take around 5 minutes or so and you should see a similar screen.

pi asterisk freepbx install 02

Once completed, take out your card, and insert it into the Pi and power it up...


Initial Pi Configuration

You will need to SSH into your pi using the terminal or an SSH client like putty.  You will also need to know the IP address of your Pi.  You can follow the first part of my guide Raspberry Pi setup without a Display, where I go into details on how to locate the IP address of your Raspberry Pi.  You may also be able to access your Pi using the hostname or hostname.local instead of the IP Address (depending on your working computer and the network)  The default hostname is raspbx.

*Note - If using a static IP address on your Raspberry Pi, be sure to manually disable the DHCP client on your network interface.  See the Troubleshooting section below.

 - Logging into the console of the Raspberry Pi

Default Credentials:

  • Login: root
  • Password: raspberry

other credentials for reference

  • Mysql root password: raspberry
  • FreePBX Login: admin
  • FreePBX Password: admin

SSH into your pi (replace the IP address in the command below, with the IP address of your Pi)

ssh This email address is being protected from spambots. You need JavaScript enabled to view it.

or try to SSH into your pi with the hostanme

ssh root@raspbx


ssh This email address is being protected from spambots. You need JavaScript enabled to view it.


pi asterisk freepbx install 03

Now update to the latest additions


Hit Y if it wants to install updates, this may take a few minutes to complete all of the updates.

Configure Timezone


Scroll to select your appropriate timezone and hit enter

pi asterisk freepbx install 04

 - Setting the timezone for Asterisk

In the previous example, we set the timezone for the Raspberry Pi itself.  Now we need to set the time zone for Asterisk/FreePBX.  Typically this is done with the FreePBX web interface and selecting Admin > System Admin.  We are running on a Raspberry Pi, and from what I can find with google, this module is not compatible with the pi's architecture, and there for not installed.  So we need to edit it manually through the console.

View the contents (ls) of the directory /usr/share/zoneinfo and find your time zone

ls /usr/share/zoneinfo
ls /usr/share/zoneinfo/US

then copy (cp) your timezone over to /etc/localtime (replace US/Central, with your correct timezone)

cp /usr/share/zoneinfo/US/Central /etc/localtime

pi asterisk freepbx install 07

You will have to restart, in order for this change to take effect, I simply reboot



- Expanding the Filesystem (For cards larger than 4GB)

In order to have the ability to use the entire card, you'll need to expand the file system (Expanding the partition across the entire card)

View the size of the partition (which is /dev/root)

df -h

pi asterisk freepbx install 08

Here is a 16GB Micro SD card, but you can see only 3.5G is used.

Run the raspi-config setup


choose 1. Expand Filesystem

pi asterisk freepbx install 09

You should then see the message Root partition has been resized.

pi asterisk freepbx install 10

Then tab to Finish and hit enter, and reboot Yes

After reboot, log back in and issue the df-h command, you will now see the /dev/root partition is the correct size for your card.

pi asterisk freepbx install 11


Asterisk / FreePBX Basic Configuration

 - Logging into FreePBX with your web browser

Now everything has been updated, we can goto a web browser and type in the IP address of your pi, you will see the FreePBX main screen

pi asterisk freepbx install 05

Click on FreePBX Administration

Login: admin / Password: admin

Once logged in, Click on Applications > Extensions

Click on Add Extension > Add New Chan_SIP Extension


We will add a basic extension so that we can register a SIP client (either from our PC or our phone) that is connected on the same network as the RasPBX Raspberry Pi 2.

Edit the following fields, then click Submit

  • User Extension: This can  be any number you'd like that should follow a dial plan that fits your needs (1000-sales, 2000-engineering, etc), For this example I use 1000
  • Display Name: This is typically your First and Last Name, for this example I use my name Algis Salys
  • Secret: This is the password that is needed, for extensions to register, for testing purposes, I just made it 1000.  This typically should be a long length of a combination of alpha-numeric characters

pi asterisk freepbx install 06

*Note: When you have made all the nessesary changes, and Clicked on Submit, now also Click on Apply Config located at the top right of the screen.


- Logging into SIP Client and Registering

Now that we created the extension 1000, we will attempt to register a SIP client to our new VoIP server for testing.  There are many software apps that you can use either on your PC or phone.  Some of the popular ones I've used are 3cx, Bria, CSIPSimple.  I'm using CSipSimple on my Android phone in this example, if you are using a different client, there maybe some variations in naming but  it should be similar enough to this example. 

For this example, you will need;

  • Your phone or PC to be on the same network as the Pi
  • IP Address of the Pi
  • User Name/Account Name
  • Password Of User (named Secret in our FreePBX extension)

In CSIPSimple, I click on add Account > Basic

  • Account Name: Algis Salys
  • User: 1000
  • Server: <IP-Address-Of-Pi>, in my case it's
  • Password: 1000

Your client should now be registered to your new RasPBX VoIP server. 

*Note the password of 1000, is only as  a simple test example, you should use very complex lower/upper-case alphanumeric passwords of a significant length (no less than 12 characters)


 - Testing a call

There are no other extensions provisioned yet in our server, but we can still do some basic tests, to ensure we can receive and transmit audio.

From you registered SIP Client dial *43,  This is an echo test where you should here a short introduction, and then you can speak and here yourself echo back.

If you click on Admin > Feature Codes for more similar test extensions.



- Forbidden

When rolling out anything like this, you should take it step by step and test along the way, as we have shown in this example.  One of the most popular errors you may have is with registering your Sip client.  This is why we want to start with it being on the same network as well as simple passwords.  If you do receive a message Forbidden on your Sip client, be sure

  • the password is correct
  • the port is correct (some Sip clients may require to put in a port along with the IP address of the Sip Server, this is by default 5060)

You can also view different logs on your Asterisk server through the FreePBX Administration web interface.  Click on Reports > Asterisk Info and this screen will show you how many extensions are actively registered.  You can also click on Reports > Asterisk Logfiles and scroll through to see if you can retrieve any specific errors about your issue.


- DHCP and Static IPs

Initially I was able to register clients, but certain clients were not able to hang-up calls properly.  I went into the asterisk console

asterisk -rvvvv

then I turned on sip debug

sip set debug on

This allows me to see registration info as well as call flow.  I noticed some ack errors due to different IP addresses on the server.  My Raspberry Pi Asterisk server had 2 IP addresses!

If you only have your Raspberry Pi set to DHCP, this is not a problem, but I went ahead and statically assigned an IP address in /etc/network/interfaces, but for some reason with the Raspbian image I am using, setting up a static IP does not disable it from also receiving a DHCP address. The confusing part was running


only showed my static IP, the way I confirmed the 2 addresses, was to run a nmap scan from another host computer.

The fix...

First you need to be sure you properly setup your /etc/network/interfaces file to set a static IP, then

Edit /etc/dhcpcd.conf

nano /etc/dhcpcd.conf

and at the end of the file,add the line

denyinterfaces eth0

Substitute the interface eth0 if using a different interface.  Reboot your Pi, and you will no longer receive a DHCP address on eth0.  



Asterisk, along with the front end FreePBX is a powerful communications platform.  The basic installation on a Raspberry Pi 2 is fairly straight forward as shown in this example but this platform does contain many more advanced features that you can completely customise to meet your needs.  If it's for your home, small business, or R&D projects, this solution is sure to meet your needs in the VoIP world.





Raspberry Pi Model:

Raspberry Pi 2 Model B

Raspberry Pi Image:

Raspbx Beta raspbx-25-01-2016

cat /etc/*-release:

Raspbian GNU/Linux 8 (jessie)


4.1.15-v7+ GNU/Linux


Asterisk 11.21.0


FreePBX 13.0.51




Read 97126 times Last modified on Thursday, 10 March 2016 20:49
Algis Salys

Creator and owner of  Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.