35 0 1MB
AlgisSalys.com - electronics, amateur ham radio, security and more (/) Search...
Friday, 05 February 2016 15:55
Asterisk + FreePBX + Raspberry Pi 2 = VoIP Sip Server Written by Algis Salys (/how-to/author/778-algissalys) font size
Print (/how-to/asterisk-freepbx-raspberry-pi-2-voip-sip-server? tmpl=component&print=1) Email (/component/mailto/? tmpl=component&template=protostar&link=8d17d206250822904307c5887682d4a690da7b88)
Rate this item
Home (/) Amateur Radio (/amateur-radio) Electronics (/electronics) How-To (/how-to) Network & Security (/network-security) Tech Notes (/tech-notes) Contact (/contact) About (/about-algissalyscom)
(8 votes)
WHAT'S POPULAR how-to
How-To: Raspberry Pi multiple WiFi setup through the command line (/how-to/how-toraspberry-pi-multiplewifi-setup-through-thecommand-line)
(/media/k2/items/cache/4147ca3af8bf81f64b5d738c371bfecb_XL.jpg)
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-
(/how-to/how-toraspberry-pi-multiplewifi-setup-through-thecommand-line) Asterisk + FreePBX + Raspberry Pi 2 = VoIP Sip Server (/howto/asterisk-freepbxraspberry-pi-2-voip-sipserver)
(/how-to/asteriskfreepbx-raspberry-pi-2voip-sip-server) Format / Partition a USB flash thumb drive on Asuswrt routers (/howto/format-and-partitionusb-asuswrt-routers) (/how-to/format-andpartition-usb-asuswrtrouters)
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!
Freeswitch 1.7 + Raspberry Pi 2 = VoIP Sip Server (/howto/freeswitch-1-7raspberry-pi-2-voip-sipserver)
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 (/how-to/freeswitch1-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)
(/how-to/freeswitch-1-7raspberry-pi-2-voip-sipserver) Nokia 5110 LCD on Raspberry Pi (/howto/nokia-5110-lcd-onraspberry-pi)
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 (http://www.raspberry-asterisk.org), 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 http://www.raspberry-asterisk.org/downloads/ (http://www.raspberry-asterisk.org/downloads/), currently of this writing, it is the latest beta version raspbx-25-01-2016.zip 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.
(/how-to/nokia-5110-lcdon-raspberry-pi)
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 (/how-to/how-to-write-a-raspberry-piimage-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 download...it took me close to 2 hours. wget http://download.raspberry-asterisk.org/raspbx-25-01-2016.zip
Unzip unzip raspbx-25-01-2016.zip
Run this while you Insert your Micro SD card watch 'dmesg | tail -20'
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_01.png)
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)
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= of=/dev/
example: sudo dd bs=4M if=raspbx-25-01-2016.img of=/dev/sdc
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_02.png)
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.
Once completed, take out your card, and insert it into the Pi and power it up...
Initial Pi Con guration 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 (/how-to/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 [email protected] (mailto:[email protected])
or try to SSH into your pi with the hostanme ssh root@raspbx
or ssh [email protected] (mailto:[email protected])
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_03.png)
Now update to the latest additions raspbx-upgrade
Hit Y if it wants to install updates, this may take a few minutes to complete all of the updates. Configure Timezone configure-timezone
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_04.png)
Scroll to select your appropriate timezone and hit enter
- 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
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_07.png)
You will have to restart, in order for this change to take effect, I simply reboot 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)
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_08.png)
df -h
Here is a 16GB Micro SD card, but you can see only 3.5G is used. Run the raspi-config setup raspi-config
choose 1. Expand Filesystem
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_10.png)
You should then see the message Root partition has been resized.
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.
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_09.png)
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_11.png)
Asterisk / FreePBX Basic Con guration - Logging into FreePBX with your web browser
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_05.png)
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
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
(https://www.algissalys.com/images/articles/asterisk-freepbx-raspberry-pi-2-voip-sip-server/pi_asterisk_freepbx_install_06.png)
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
*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: , in my case it's 192.168.138.183 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.
Troubleshooting - 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 ifconfig
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.
Conclusion 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. References: 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) Kernel: 4.1.15-v7+ GNU/Linux Asterisk: Asterisk 11.21.0 FreePbx: FreePBX 13.0.51 http://www.raspberry-asterisk.org (http://www.raspberry-asterisk.org) http://wl500g.info/showthread.php?14885-Asterisk-Incorrect-time-in-CDR (http://wl500g.info/showthread.php?14885-Asterisk-Incorrect-time-in-CDR)
Read 55299 times Tweet
Last modified on Thursday, 10 March 2016 20:49
Like 3 people like this. Sign Up to see what your friends like.
Published in How-To Articles and Tutorials | algissalys.com (/how-to) Tagged under voip (/how-to/tag/voip) sip (/how-to/tag/sip) asterisk (/howto/tag/asterisk)
Algis Salys (/how-to/author/778-algissalys) Creator and owner of algissalys.com (http://www.algissalys.com). Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.
More in this category: « SickRage + Sabnzbd + Raspberry Pi = TVPi Part 2 (/howto/sickrage-sabnzbd-raspberry-pi-tvpi-part-2) WebRTC / Asterisk Support Guide » (/how-to/webrtc-asterisk-support-guide) back to top (/how-to/asterisk-freepbx-raspberry-pi-2-voip-sip-server#startOfPageId223)
© 2018 AlgisSalys.com - electronics, amateur ham radio, security and more
Back to Top