In an older post, “IncrediblePBX (Asterisk/FreePBX) ESXi Installation with Google Voice”, I touched on installing a variant of Asterisk/FreePBX called IncrediblePBX in a virtual machine. This time however, I’d like to focus on installing this cool piece of software on a Raspberry Pi (either a version 2 or 3). Luckily the IncrediblePBX folks have graciously provided a Raspberry Pi version for us to use.
As a bonus for the readers, I’d like to go into much more detail for a complete installation for residential use. Yes, starting from scratch! Basically, this includes demystifying some of the VoIP (Voice Over Internet Protocol) jargon that initially caught me off guard and showing you all that I’ve learned in the process of setting up mine. So if you are ready to embark on a new journey, brace yourself it’s gonna get bumpy!
For starters, this guide assumes you are somewhat comfortable with the Raspberry Pi (i.e.: writing images, simple configurations changes, and you have a certain ease with the Linux command line and SSH.
Why go through all this trouble you say? What are the benefits? Why should I not continue to fork over my hard earned cash to my regular good-for-nothing Telco? Let me tell you.
Cool Stuff You Can Do
- Place cheap or free phone calls
- Intercom features (if you have SIP phones, basically auto-answer internal intercom calls)
- Have others dial in and use your provider(s) (probably not what you want, but cool nonetheless)
- VPN into your network via your smartphone and place calls for free wherever you have WiFi
- Voice mail to MP3 sent to your Email
- KODI notifications on your TV so you can avoid your mother-in-law without even checking the phone!
- Put to use that Raspberry Pi you have collecting dust in your room.
- So much more…
- A Raspberry Pi (version 2 or 3)
- All the paraphernalia needed for the Pi (SD Card, Power adapter, keyboard…)
- A primary VoIP account
- A Google Voice account (Optional, but nice to have)
- A SIP phone, alternatively a normal analog phone and an ATA device, alternatively a softphone (any of these would do)
- A USB headset for the softphone
- Some time away from the wife/girlfriend/mistress…
In this series of blog posts, I hope to cover the following:
- Initial installation of IncrediblePBX on the Raspberry Pi (Part 1)
- Setting a static IP address for the Raspberry Pi (Part 1)
- Configuration of GMail as a SMTP relay host for SendMail (Part 1)
- Google Voice setup (Part 1)
- G.729 codec installation (Part 1)
- Softphone installation (Part 1)
- Home Setup Configuration (Part 2)
- Custom KODI notfication on incoming calls (Part 3)
- Custom KODI notfication/SMS on voice mails (Part 3)
Download the image
Let’s first proceed to download the IncrediblePBX 13 image from here. Download the GV OAuth version if you have a Google Voice account and plan to add it to IncrediblePBX.
Copy Image to a MicroSD Card
See here, if you are already confused (jeez, I hope not!)
Boot the Raspberry Pi from the microSD card and login to Raspberry Pi console as pi:raspberry to initialize your server. Take note of your server IP address and reboot.
Login via SSH as root:password to randomize passwords & configure firewall.
Change your root password if it’s insecure:
Set your Incredible GUI admin password:
Set your web apps admin password:
htpasswd /etc/pbx/wwwpasswd admin
Set your correct time zone:
Optionally, you can install the fax software by running the following command (won’t be covered in this post though).
I generally like to give all my servers a static IP, this box is no different. You can proceed by adding the following to the file /etc/dhcpcd.conf with your favorite text editor and rebooting (of course change the IP address for your own).
interface eth0 static ip_address=192.168.1.99/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
GMail as a SMTP Relay Host for SendMail Setup
We’ll need an account to email from within our IncrediblePBX box for stuff like voice mails. Create a GMail account if you don’t already have one, and note down the credentials.
This step is somewhat complex, but here’s how I got it working. Credit goes to the folks over at PBXinaflash for getting this all working. Let’s first add the domain pbx.dyndns.org to your /etc/hosts file. So it looks as such (I believe the domain could be anything, doesn’t have to be real for this to work).
127.0.0.1 pbx.dyndns.org pbx.local localhost ...
And then make line 15 of /etc/asterisk/vm_general.inc look like the following:
Next preform all of the following:
cd /etc/mail hostname -f > genericsdomain touch genericstable makemap -r hash genericstable.db < genericstable mv sendmail.mc sendmail.mc.original wget http://nerdvittles.dreamhosters.com/pbxinaflash/source/sendmail/sendmail.mc.gmail cp sendmail.mc.gmail sendmail.mc mkdir -p auth chmod 700 auth cd auth echo AuthInfo:smtp.gmail.com \"U:smmsp\" \"I:user_id\" \"P:password\" \"M:PLAIN\" > client-info echo AuthInfo:smtp.gmail.com:587 \"U:smmsp\" \"I:user_id\" \"P:password\" \"M:PLAIN\" >> client-info echo AuthInfo:smtp.gmail.com:465 \"U:smmsp\" \"I:user_id\" \"P:password\" \"M:PLAIN\" >> client-info
Stop here and edit the client-info file you just created (nano -w client-info). Replace user_id with your GMail account name without @gmail.com and replace password with your real GMail password. Be sure to have the double-quotes if they don’t appear in the file!!! Save your changes (Ctrl-X, Y, then Enter).
chmod 600 client-info makemap -r hash client-info.db < client-info cd .. yum -y install sendmail-cf make service sendmail restart
Finally let’s give it a test. Hopefully this works for you, if not more info could be had at the PBXinaflash forums.
echo "incrediblePBX" | mail -s test <your_email address>
Google Voice Setup (Optional)
If you want to set up Google Voice at this point (and you have downloaded the GV OAuth version of the IncrediblePBX image) then proceed to this link to create your OAuth tokens and enter your new Google Voice credentials in the GUI.
Hopefully the status reads Connected and you’re good go and have a Google Voice trunk. More on trunks later…
Compiling the G.729 codec for ARM on Raspberry Pi 2 (Optional)
The G.729 codec, which does not come with IncrediblePBX (due to licensing), is a standard Codec for private branch exchange (PBX) setups and can be helpful to cut bandwidth requirements without sacrificing call quality (assuming both ends of the conversation supports it). This is how I got it compiled on the Raspberry Pi 2. Credit goes to this link, with slight modification for the RPi2.
In order to avoid a heavy usage of the sdcard, it is possible to build a temporary tmpfs folder for compilation.
cd /tmp mkdir tmpfs sudo mount -t tmpfs tmpfs tmpfs cd tmpfs
After that, we compile the bcg729 library. The default output path of the library files should be changed to /lib as Asterisk can not find it when loading the G.729 codec.
wget http://download-mirror.savannah.gnu.org/releases/linphone/plugins/sources/bcg729-1.0.0.tar.gz tar xzf bcg729-1.0.0.tar.gz cd bcg729-1.0.0 ./configure --libdir=/lib make sudo make install
The next step is to compile the G.723 and G.729 codecs with bcg729 and copy them to /usr/lib/asterisk/modules folder.
wget http://asterisk.hosting.lv/src/asterisk-g72x-1.3.tar.bz2 tar xjf asterisk-g72x-1.3.tar.bz2 cd asterisk-g72x-1.3
Then alter the file configure.ac for the Raspberry Pi 2’s architecture (this may be different for the RPi3!?).
Line 32 should read:
Finally proceed with compilation and check if you see g729 with the following command.
./autogen.sh ./configure --with-bcg729 --with-asterisk-includes=/usr/include --with-asterisk130 make sudo make install
sudo systemctl asterisk restart sudo asterisk -rvvv
Like I mentioned in the Requirements section, you can connect any kind of telephone to the PBX. The normal analog type phones you probably have, need a way to directly interface with your PBX (which is presumably on your network right now and connected to a switch/hub/router in your house). What this means is that you first connect your phone to an analog telephone adapter (ATA) like the ObiHai’s OBi200, then connect the ATA to your router with a network cable and then configure the ATA (via its own software) to connect to your PBX. But we won’t dwell too much on this kind of setup as this is added trouble for nothing at this point.
Alternatively though, you could simply use a softphone like YateClient, which is free!
What are you waiting for, download it now! I’m waiting…
Once installed you’ll now need the IP address of your IncrediblePBX server. Login with your admin password (as configured above) and navigate to Applications -> Extensions -> 701 to get the SIP password/secret for the 701 extension.
Once you are registered to extension 701, close the Account window. Hook up your USB Headset, do configure it if necessary, and then click on YATE’s Telephony Tab and place some test calls to the numerous apps that are preconfigured on IncrediblePBX. Try some of these to get started:
DEMO - Apps Demo 123 - Reminders 947 - Weather by ZIP Code 951 - Yahoo News *61 - Time of Day TODAY - Today in History
All right, that should about do it for the initial configuration. Meet me over in Part 2, where we’ll configure IncrediblePBX for home use, and where the real fun begins!