Building A PBX Part 4 — Hooking Up A Rotary Phone

This article is one in a series about building a PBX. If you haven’t already, please check out the first in the series, Building A PBX Part 1 — PBX Hardware.

So now that we a touch tone phone configured to work with our PBX, let’s focus on getting a rotary phone working. As mentioned briefly in part 3 of this PBX setup, rotary phones rely on pulse dialing, while touch-tone phones rely on tone dialing. Most ATAs (Analog Telephone Adapters. If you don’t know what this is, you should really read part 3) don’t support pulse dialing, meaning that if you hooked a rotary phone up to one, you wouldn’t be able to call out from it.

A cheap adapter that supports pulse dialing is the Grandstream HT502, which you can buy used for about $20 USD on marketplaces like eBay. Not only does the HT502 support pulse dialing, but it has two independent telephone ports, allowing you to configure two different phones (with different extensions!) through one ATA. This adapter was recommended to me by FozzTexx, and I have him to thank for introducing me to it.

Now that we have our HT502, we need to do some initial setup on the PBX to communicate with it. Log in to Incredible PBX via the web interface and go to Applications >> Extensions. There will probably be some existing extensions there, but we want to make a new one. So we can press the ‘Add Extension’ button, and choose ‘Add New CHAN_SIP Extension’ from the drop-down. CHAN_SIP is an older alternative to PJSIP, both of which are SIP protocol implementations. We need to use CHAN_SIP for the HT502 as it can only connect to the PBX at port 5060 for un-encrypted SIP traffic (PJSIP listens on port 5061).

Now we can fill out information for a new extension that will correspond to our phone on the General tab. Pick a User Extension (like 4321, something users on your PBX will dial to reach our), a Display Name (a nickname to identify this extension), and a Secret (just a password for this extension). Below in User Manager Settings, we will create a new user on the PBX for this extension. Under Link to a Default User, select Create New User, and then check the box below for Use Custom Username before adding a name into the Username field (I use the extension for this). Below, enter a password in Password for New User (I use the same one specified for Secret above).

The General Tab, under Add SIP Extension.

Now click on the Voicemail tab so we can set up some basic voicemail functionality. Under Enabled, select Yes to turn voicemail on, and provide a Voicemail Password (something 4-digits long, easy to enter via your phone works well). Optionally, toggle the selections for Require From Same Extension (so you need to enter the voicemail password when calling from your extension) and Disable (*) in Voicemail Menu (which allows access to the voicemail menu remotely) to Yes and No respectively. Additionally, you can supply an Email Address for voicemail notifications to be sent to, and you can toggle Play CID to Yes, which will read back the caller’s phone number before playing a voicemail.

The Voicemail tab, under Add SIP Extension.

We will leave all other settings on this and other tabs untouched, so press the ‘Submit’ button to save this extension.

Now, navigate to Applications >> IVR to get to the IVR (Interactive Voice Response) list. We will be modifying the DemoIVR, so click on the Edit icon for DemoIVR. We will be modifying the IVR so that when someone calls into our PBX, they can dial our extension and ring our phone.

The IVR page, under Applications.

Scroll all the way to the bottom of the Edit IVR: DemoIVR page to the IVR Entries section. You should have a blank box at the bottom under the Digits column, but if not, press the button titled ‘+ Add Another Entry’ to add a blank row. In the empty row, enter your extension (from earlier) in the Digits column (I use 4321), and from the drop-down in the Destination column, choose Extensions and then select your extension from earlier in the drop-down directly below (mine reads 4321 Rotary). When done, press the ‘Submit’ button to save the IVR.

Adding an IVR Entry to DemoIVR.

Finally, press the big red ‘Apply Config’ button at the top right of the page. This will apply the new config and make our extension/IVR changes live.

Now we need to configure our HT502 device. Physical setup is very easy. Plug the telephone into the Phone1 RJ-11 jack of the HT502 using an RJ-11 cable. Similarly, plug an ethernet cable into the RJ-45 jack labeled WAN on the HT502, and plug the other end into a spare jack on a network switch in the same LAN as your PBX. Finally, connect the power adapter up between the HT502 and mains, which will automatically boot the device (it will now light up some green LEDs). At this point, it is probably a good idea to factory reset the device by holding down the reset button on the HT502with a paperclip until it restarts (about 7 seconds). This will clear any old/junk configurations.

The HT502 up and running.

By default, the HT502 doesn’t allow web administration access over the WAN port, so you must either connect a computer to the LAN port of the HT502 to access the web interface, or connect a touch-tone phone (only for this step) into the Phone1 port to enable web access. If you opt to connect a touch-tone phone, the HT502 must be configured through the built in IVR. Pick up the handset on the phone and dial *** to launch the IVR. Then, dial 12 for the menu item corresponding to WAN port access. Finally, dial 9 to toggles the WAN port access on. You should recieve an audio confirmation that access is enabled, so you can hang up the call.

Now, check your router or nmap scan your network to find the IP address of the HT502 and visit it in a browser. We will be prompted for a password (admin) which we will need to enter to get to the dashboard to continue configuration.

From the top navigation, go to FXS PORT1 to configure SIP settings. Under Account Active, select Yes. For Primary SIP Server and Outbound Proxy, enter the IP address of our PBX. For SIP User IDAuthenticate ID, and Name, enter the extension we set up earlier (I’m using 4321). Under Authenticate Password, enter our Secret (password) that we used when setting up the extension. Finally, under DNS Mode, select Use Configured IP. Everything else should be fine as the default configuration.

Configuring FXS Port1 on the HT502.

When done, scroll to the bottom of the page and press the button for ‘Update’. The page will then reload, so scroll down to the bottom and press the button for ‘Apply’ to apply our settings.

After a few seconds, you should be able to go to STATUS via the top navigation and see our extension registered with the PBX.

FXS 1 is reading as Registered.

After giving the device enough time to reboot (about 5 seconds from what I’ve seen), we can now test incoming and outgoing calls to our phone. I’m testing using an old (and filthy) Western Electric 500.

The Western Electric 500.

To test incoming calls, from an external line (like a cell phone) dial the DID number to access the PBX (as you did in part 2 and part 3). When you can hear the IVR provide you with options, enter the extension we set up (4321), and wait a second or two. Your touch-tone phone should start ringing, allowing you to pick it up and connect the call!

To test outgoing calls, pick up the handset on your touch-tone phone (the one configured in this guide to work with the PBX) and dial 1 followed by an external phone number (like your cell phone). For example, if my cellphone had the number 555-123-4567 I would dial 1-555-123-4567 to place an outgoing call  (1 has been set up to dial out). Within a few seconds, the call should come in to your cell phone (or whatever external phone you are using) and even display the outbound CID you specified earlier as the caller ID (pretty cool, huh? Talk about easy spoofing). Answer the call to test if you can hear both sides of the conversation!

If you followed along with part 3, you should now have two phones configured on the PBX. Not only can these phones make and take calls externally, but they can also call each other! From Your rotary phone, dial 1234 (or whatever extension you used when setting up your touch-tone phone) to call your touch-tone phone, or from your touch-tone phone dial 4321 (or whatever extension you used when setting up your rotary phone) to call your rotary phone!

You should now have a rotary phone configured with your PBX that can make and receive calls! If you can’t seem to properly make or receive a call, check the config on both the PBX and HT502 to see if anything looks incorrect.

 

Building A PBX Part 3 — Hooking Up A Touch-Tone Phone

This article is one in a series about building a PBX. If you haven’t already, please check out the first in the series, Building A PBX Part 1 — PBX Hardware.

So now that we have incoming and outgoing calls configured on the PBX, we can actually hook up a touch-tone phone to make and receive calls!

Your standard phone is going to have an RJ-11 jack to interface with telecommunications equipment, but of course our Raspbery Pi setup doesn’t have any sort of dial-up modem card or anything that might make some sort of sense when it comes to wiring everything up.

We need what is known as an ATA (Analog Telephone Adapter), a device that sits on the local area network and interfaces with our PBX via TCP/UDP, while also simulating a traditional telephone network connection for our physical phone to use.

I purchased a very basic OBi100 ATA device to use with my touch-tone phone. It is important to note at this point that not all adapters support older rotary phones (which use pulse dialing, but more on that in a future article); pretty much any ATA will support touch-tone phones (which use tone dialing). That said, a lot of these devices have very cryptic configurations, and it might be difficult to find how to use them. The OBi100 has been discontinued, but it is fairly well documented and available used for around $10-$20 USD on sites like eBay.

Now that we have our OBi100, we need to do some initial setup on the PBX to communicate with it. Log in to Incredible PBX via the web interface and go to Applications >> Extensions. There will probably be some existing extensions there, but we want to make a new one. So we can press the ‘Add Extension’ button, and choose ‘Add New PJSIP Extension’ from the drop-down.

Now we can fill out information for a new extension that will correspond to our phone on the General tab. Pick a User Extension (like 1234, something users on your PBX will dial to reach our), a Display Name (a nickname to identify this extension), and a Secret (just a password for this extension). Below in User Manager Settings, we will create a new user on the PBX for this extension. Under Link to a Default User, select Create New User, and then check the box below for Use Custom Username before adding a name into the Username field (I use the extension for this). Below, enter a password in Password for New User (I use the same one specified for Secret above).

The General Tab, under Add PJSIP Extension.

Now click on the Voicemail tab so we can set up some basic voicemail functionality. Under Enabled, select Yes to turn voicemail on, and provide a Voicemail Password (something 4-digits long, easy to enter via your phone works well). Optionally, toggle the selections for Require From Same Extension (so you need to enter the voicemail password when calling from your extension) and Disable (*) in Voicemail Menu (which allows access to the voicemail menu remotely) to Yes and No respectively. Additionally, you can supply an Email Address for voicemail notifications to be sent to, and you can toggle Play CID to Yes, which will read back the caller’s phone number before playing a voicemail.

The Voicemail tab, under Add PJSIP Extension.

We will leave all other settings on this and other tabs untouched, so press the ‘Submit’ button to save this extension.

Now, navigate to Applications >> IVR to get to the IVR (Interactive Voice Response) list. We will be modifying the DemoIVR, so click on the Edit icon for DemoIVR. We will be modifying the IVR so that when someone calls into our PBX, they can dial our extension and ring our phone.

The IVR page, under Applications.

Scroll all the way to the bottom of the Edit IVR: DemoIVR page to the IVR Entries section. You should have a blank box at the bottom under the Digits column, but if not, press the button titled ‘+ Add Another Entry’ to add a blank row. In the empty row, enter your extension (from earlier) in the Digits column (I use 1234), and from the drop-down in the Destination column, choose Extensions and then select your extension from earlier in the drop-down directly below (mine reads 1234 TouchTone). When done, press the ‘Submit’ button to save the IVR.

Adding an IVR Entry to DemoIVR.

Finally, press the big red ‘Apply Config’ button at the top right of the page. This will apply the new config and make our extension/IVR changes live.

Now we need to configure our OBi100 device. Physical setup is very easy. Plug the telephone into the RJ-11 jack of the OBi100 using an RJ-11 cable. Similarly, plug an ethernet cable into the RJ-45 jack of the OBi100, and plug the other end into a spare jack on a network switch in the same LAN as your PBX. Finally, connect the power adapter up between the OBi100 and mains, which will automatically boot the device (it will now light up some green LEDs). At this point, it is probably a good idea to factory reset the device by holding down the reset button on the OBi100 with a paperclip until it restarts. This will clear any old/junk configurations.

The OBi100 up and running.

Now, check your router or nmap scan your network to find the IP address of the OBi100 and visit it in a browser. We will be prompted for a username and password (admin/admin) which we will need to enter to get to the dashboard to continue configuration.

On the left navigation, click on Service Providers >> ITSP Profile A >> SIP to view our SIP configuration. Uncheck the check-boxes in the Default column for ProxyServer and ProxyServerPort. Under the Value column for ProxyServer, put the IP address of our PBX. Under the Value column for ProxyServerPort, put 5061 (The port PJSIP is using on our PBX).

SIP configuration, under ITSP Profile A.

Now scroll down to the bottom of the page and press the ‘Submit’ button. You will now be at a confirmation page, but we aren’t done just yet.

On the left navigation, go to Voice Services >> SP1 Service. On the SP1 Service page, under SIP Credentials, uncheck the boxes under the Default column for AuthUserName and AuthPassword. Under the Value column, for AuthUserName enter our extension number (I used 1234) and for AuthPassword enter our extension Secret (the password we set for the extension).

SIP Credentials, under SP1 Service.

Again, Now scroll down to the bottom of the page and press the ‘Submit’ button. On the resulting confirmation page, press the ‘Reboot’ button in the top right corner to reboot the device. This will apply the new configuration we specified after the device boots after a few seconds.

The OBi100 confirmation page.

After giving the device enough time to reboot (about 5 seconds from what I’ve seen), we can now test incoming and outgoing calls to our phone. I’m testing using an old (and filthy) Western Electric 2500.

The Western Electric 2500.

To test incoming calls, from an external line (like a cell phone) dial the DID number to access the PBX (as you did in part 2). When you can hear the IVR provide you with options, enter the extension we set up (1234), and wait a second or two. Your touch-tone phone should start ringing, allowing you to pick it up and connect the call!

To test outgoing calls, pick up the handset on your touch-tone phone (the one configured in this guide to work with the PBX) and dial 1 followed by an external phone number (like your cell phone). For example, if my cellphone had the number 555-123-4567 I would dial 1-555-123-4567 to place an outgoing call  (1 has been set up to dial out). Within a few seconds, the call should come in to your cell phone (or whatever external phone you are using) and even display the outbound CID you specified earlier as the caller ID (pretty cool, huh? Talk about easy spoofing). Answer the call to test if you can hear both sides of the conversation!

You should now have a touch-tone phone configured with your PBX that can make and receive calls! If you can’t seem to properly make or receive a call, check the config on both the PBX and OBi100 to see if anything looks incorrect.

 

Building A PBX Part 2 — Configuring Incoming & Outgoing Calls

This article is one in a series about building a PBX. If you haven’t already, please check out the first in the series, Building A PBX Part 1 — PBX Hardware.

So now we’re ready to configure our PBX to interact with the global telephone network. This means that anyone in the world can call into our PBX, and we can call out.

Much like needing an ISP to connect a home network to the Internet, we will need a VoIP provider to hook into the telephone network.

There are many VoIP providers out there, but I chose VoIP.ms based on their pricing model. At the time of writing, their most basic plan costs $0.85 USD a month for incoming calls with an additional $0.009 USD per minute, and $0.01 USD per minute for outgoing calls. You can do quite a bit of experimentation with these rates for less than the cost of a cup of coffee. However, you need to note that you can only deposit funds into your account in increments of $25.00, so you will need to invest that much up-front. This initial deposit could last you for years depending on your usage.

After registering an account and depositing funds, log in to the customer portal and go to DID Numbers >> Order DID(s) in order to register a DID (Direct Inward Dialing) number. This number is what everyone will eventually call to access our PBX. The process is relatively simple, allowing you to pick an area code, and even do some searching if you want any of the digits to be in a certain order to spell out a word, or anything like that. Of course, you have to pick from a pool of numbers that aren’t already being used.

After we have our DID number, we need to configure our DID Routing by going to Main Menu >> Account Settings and clicking the DID Routing tab. From here, we can choose a POP server that is physically close to our PBX (for lower latency) and make sure that the Routing is set to SIP/IAX for our main account. When done, hit the ‘Apply All’ button at the bottom of the page. At this point, we can also take a little time to explore all of the options under account settings. Most options can be left as they are, but some like disabling international calls can safe-guard against mis-configurations and higher bills.

Choosing a server through VoIP.ms’ control panel.

Now we need to configure the PBX to actually use VoIP.ms. Log in to FreePBX and go to Connectivity >> Trunks. Here, we will edit the VoIPms trunk that is already pre-configured (minimally) in Incredible PBX. If you don’t have this trunk already, you can press the ‘Add Trunk’ button to create a new one (chan_sip should work just fine if it prompts you). “Trunking” is a method  in telecommunications that lets a system service many clients (like a tree trunk with many branches). From our perspective, this means that many people will be able to call in and interact with our PBX at once.

The Incredible PBX Trunks page.

On the General tab, give the trunk a name and an Outbound CallerID if you’d like (the number others will see calls coming from).

The General tab, under Edit Trunk.

On the Dialed Numbers Manipulation Rules tab, edit the dial patterns so the look like the following:

()  | 1NXXNXXXXXX
(1) | NXXNXXXXXXX
()  | NXXXXXX

The Dialed Number Manipulation Rules tab, under Edit Trunks.

On the sip Settings tab, enter the following configuration using your username (a sip username emailed to you from VoIP.ms, not what you log in with), secret (password you use for VoIP.ms, unless you changed it through their Account Settings), and host (you specified this when you chose a pop server, something like newyork4.voip.ms):

username=YOUR-6-DIGIT-VOIPMS-USERNAME
type=friend
trustrpid=yes
sendrpid=yes
secret=YOUR-VOIPMS-PASSWORD
qualify=yes
nat=yes
insecure=port,invite
host=YOUR-VOIPMS-POP-HOST
fromuser=YOUR-6-DIGIT-VOIPMS-USERNAME-AGAIN
disallow=all
context=from-trunk
canreinvite=nonat
allow=ulaw

The Outgoing tab, under sip Settings, under Edit Trunk.

The sip Settings tab also has a sub-tab for Incoming (you are currently on Outgoing). Click on that tab and enter a register string in the following format:

YOUR-6-DIGIT-VOIPMS-USERNAME:YOUR-VOIPMS-PASSWORD@YOUR-VOIPMS-POP-HOST:5060/YOUR-6-DIGIT-VOIPMS-USERNAME-AGAIN

The Incoming tab, under sip Settings, under Edit Trunk.

Press the ‘Submit’ button when done.

Now go to Connectivity >> Inbound Routes and press the button for ‘Add Inbound Route’. On the General tab, modify Set Destination to IVR (Interactive Voice Response), and choose the DemoIVR. All of the other tabs should have default settings. Press the ‘Submit’ button to save.

The General tab, under Inbound Routes.

 

The Advanced tab, under Inbound Routes.

 

The Privacy tab, under Inbound Routes.

 

The Fax tab, under Inbound Routes.

 

The Other tab, under Inbound Routes.

 

Next, go to Connectivity >> Outbound Routes and press the button for ‘Add Outbound Route’. The settings here will mostly mirror your trunk configuration. On the Route Settings tab, give the route a Route Name, and set the same Route CID you did for the trunk earlier. For the Trunk Sequence for Matched Routes setting, select the VoIPms trunk.

The Route Settings tab, under Outbound Routes.

On the Dial Patterns tab, make sure to use the same dial patterns set for the trunk earlier.

The Dial Patterns tab, under Outbound Routes.

We won’t need to change any settings on the Import/Export Settings or Additional Settings tabs.

The Import/Export Settings tab, under Outbound Routes.

 

The Additional Settings tab, under Outbound Routes.

Finally, press the big red ‘Apply Config’ button at the top right of the page. This will apply the new config and make our trunk/route changes live.

At this point, you should be able to call the DID number you got from VoIP.ms from any phone and have it reach your PBX, which will lead you to an automated menu with a few options. If you don’t get a friendly greeting and a bunch of options you can choose, check your config and see if anything looks incorrect.

We will test the outgoing calling in the next part of this guide when we set up a phone to interact with the PBX!

 

Building A PBX Part 1 — PBX Hardware

I’ve always had some sort of fascination with the telephone system. There is something that excites me about large systems in general, whether it has to do with computer networking, telephony, power, or even the postal service. Phone phreaking sort of plays into this fascination—we learn how the phone network works by poking and prodding until something interesting is discovered.

In 2012 or so, I set up by own PBX (or private branch exchange) using an original 256MB Raspberry Pi model B. The system worked great! I was able to take and place calls, hook in my trusty Western Electric phone, and play around with all of the different features I could figure out. Eventually, the system was powered down and put into a bin, mostly forgotten until earlier this year.

A few months ago I decided to resurrect my trusty PBX by completely recreating the original functionality I attained six years ago, with a few other little additions thrown in. I’ve decided to start this series of guides to document what I’ve been able to figure out (and maybe some stuff I haven’t yet). It’s for you as much as it is for me. Some of the configuration I’ve seen can be cryptic, and documentation disappears from the web constantly. It’s good to keep a set of internal documents if the system ever goes poof and need to be rebuilt. As fun as they may be, I aim to avoid those late nights gazing hopelessly at a console for who-knows-how-many hours while I try to derive some logical solution out of an elusive issue.

If you don’t know what a PBX is, it is easily equatable to a networking switch: the little box on your home network with a bunch of ethernet cables clipped into it. Your network devices communicate with one another through the switch, and possibly with other devices over the Internet if the switch is connected up to a router and modem. A PBX operates in a similar matter, with phones (physical or software-based) connecting to one another through it at a local site or to other phones in the telephone network, all over the world.

I wanted to accomplish a few things with my PBX, so I split functionality out into a few different areas:

1) Create a PBX using a spare Raspberry Pi. (DONE, see part 1. Wait, you’re already there.)
2) Be able to accept incoming calls. (DONE, see part 2)
3) Be able to make outgoing calls. (DONE, see part 2)
4) Connect a physical, touch-tone phone to the PBX. (DONE, see part 3)
5) Connect a physical, rotary phone to the PBX. (DONE, see part 4)

Additionally, I may expand this functionality further. I could hook up some sort of modem, install software on my PC so it can act as a phone, or even run a fax machine (thrilling, I know)!

Being that this is a learning experience, I’m also committed to spending as little money as possible (within reason). With a technology as old as telephony, there are a lot of cheap/used devices out there that can be had in abundance.

So, let’s get started with the PBX setup. Originally, I ran my installation on an older Raspberry Pi model B. It worked great then, but is definitely showing its age as software gets more and more bloated complex. In the world of open-source PBX software, the two big names you will probably hear are FreeSWITCH and Asterisk. People could discuss the pros and cons of each for hours, but for simplicity, I’ve chosen to use Asterisk as my backing system. Asterisk itself is a very old and capable piece of software, but an administrator can only configure it via editing text configuration files. This is a great way to learn the software at a low level, but I prefer to admin the system using FreePBX, a web-based GUI that sits atop Asterisk, for convenience and speed. While you can still run this fairly well on an original Raspberry Pi model B, I’d recommend at least using a Raspberry Pi 2 (like I am) if not something newer. Of course, you will also need a power adapter and a microSD card (16 GB is more than enough)

There are a few distributions that couple Asterisk/FreePBX on the Raspberry Pi, but I will be using the Debian-based Incredible PBX. Installation is easy enough if you have an SD card inserted on an exisiting Linux machine. Just make sure you do fdisk -l to determine the location of your SD card.

$ wget -O incrediblepbx13.13-raspbian8.zip https://downloads.sourceforge.net/project/pbxinaflash/IncrediblePBX13-13%20for%20Raspbian/incrediblepbx13.13-raspbian8.zip?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fpbxinaflash%2Ffiles%2FIncrediblePBX13-13%2520for%2520Raspbian%2Fincrediblepbx13.13-raspbian8.zip%2Fdownload&ts=1531600211
$ unzip incrediblepbx13.13-raspbian8.zip
$ sudo dd bs=1m if=incrediblepbx13.13-raspbian8.img of=/dev/disk4

After dd completes, you can pop the SD card into your Raspberry Pi and boot it up.

The Raspberry Pi PBX is online!

Check your router or nmap scan your network to find the IP address of the new RPi machine and visit it in a browser. The FreePBX UI should pop up and allow you to login with admin/admin.

After a successful login, you will be presented with the FreePBX dashboard.