Categories
Hardware Linux Raspberry Pi VoIP

3CX Phone System on a Raspberry Pi 4 (Part 1)

This was probably one of the most exciting things I’ve done in a long while. I’m going to apologize now for this being a long post. More important than the “How” for this entry is the “Why”. I wanted to share that with you before I get into the specific details.

A lot of folks have posted their experiences with their Raspberry Pi. I’ve wanted to try it out, but couldn’t figure out a use case that justified the expense right now. When in stock, they aren’t that expensive. However, I hate buying something just to not use it. That is, until I ran across this YouTube video by NetworkChuck. I finally found a use-case that I could buy into.

The Search for a Solution

Many years ago, I moved away from your typical telephone service. I haven’t had a “hard line” telephone number since before 2003. To many in 2022, this isn’t a new story. Most people just use their cell phones these days. Call me old fashioned, but I still cling to the need to have a “Home Telephone” number. In 2003, I signed up for Vonage as my telephone provider. It has served me well over the years. I had a constant telephone number for banks, services, etc. that moved with me wherever I went. My prior job took me around the world, and this service provided some consistency. It was a good service. But in 2021, I wanted to move on to something more flexible and cost effective.

I had a couple criteria for a replacement service:

  • Support for physical phones (VoIP or POTS)
  • US-phone number
  • Reduced monthly cost from current service
  • Professional-grade service with support

My first option was to look at Ubiquity’s UniFi Talk service. Given the fact I have a Ubiquity UDM Pro on my network, this was a natural first stop. Their VoIP solution meets many of the requirements I was looking for. They have physical VoIP phones available, but their service is limited to their specific phones. Their international rates along with their monthly service fee were definitely reasonable. But I wanted to find something with a little more flexibility. Since I don’t have any physical phones right now, I need something that supports an app on my phone. The search continued…

Back when I was working on my master’s degree, a friend’s company was using Asterisk to host their own PBX solution. As I looked through the website, I quickly realized this was going to be far too much learning for what I’m ready for. The Open Source project gives a literal ton of flexibility and options to design a complete telephone service. It also offers support for the principle standards that many of the VoIP handsets are designed for.

Then I came across the video I shared above from NetworkChuck. 3CX was a new product for me, but I liked what I saw. They offer a free option when self-hosted for a small number of telephone lines. Furthermore, they support a wide range of physical handset devices. Finally, they have a mobile app for both iOS and Android. I found a solution that I can install without incurring a service or licensing fee.

One of the features that I really like about their offering is that I can tie in my choice of SIP trunk service providers. This allows me to shop around for my telephone service without having to tie me to a given provider. That led me to Amazon Chime Voice Connector. This service is INCREDIBLY cost effective. Better yet, with a very small monthly rate per telephone number ($1 / month at the time of this writing), you only pay for the telephone calls you make or receive. Their rates are not the best out there, but they are within my allotted budget. So let’s get into the implementation details. Ready?

Hardware Selected

The best way to start is to talk about the hardware that I chose for my telephone system. The 3CX Recommended Hardware Specifications provide the minimum requirements for the system. According to their guide, this will support up to 30 extensions. Here is what I chose (with affiliate links):

This is everything I need to be able to run the Pi in my server rack using the PoE power available from my switch.

Configure Raspberry Pi

I followed the 3CX Installation Guide with a few exceptions. I’ll take note of these here. I did not use the download links from the 3CX website because I wanted to make sure I worked off of the latest images. I downloaded the Raspberry Pi Imager to create my SD card boot disk.

Running the Imager, it’s important to chose either the Raspberry Pi OS (Legacy) or Raspberry Pi OS Lite (Legacy) option. The version of 3CX that is available as of December 2021 is not compatible with Debian Bullseye-based OS’s like the current Raspberry Pi OS. It is your choice whether or not you want a desktop. I chose not to have one since I’m comfortable working with the command line.

I made an additional customization on the write. A dialog popped up and I chose to enable SSH on boot. This allows me not to have to use a keyboard and monitor on the actual device, which works well since I’m going to house this in my server rack–more on that later.

After you choose your storage and OS, click the “Write” button. It will go through the process of writing to the SD card.

Install 3CX on your Raspberry Pi

Once you boot the Pi with the newly formatted SD card, you should be able to SSH using the IP address found either by having a monitor on the system or using your switch’s monitoring capabilities. The default username is pi and the default password is raspberry.

Follow Steps 3 and 4 in the 3CX guide to configure your Raspberry Pi with a hostname, static IP, and the required packages. I would then update your Pi with the latest OS and application updates using the sudo apt update && sudo apt upgrade command. Do this BEFORE installing 3CX. You will want to reboot the Pi after the updates complete so you can validate the static IP, hostname, and OS updates were successful. When the Pi has finished rebooting, log in and type the following command to install 3CX:

wget https://downloads-global.3cx.com/downloads/misc/d10pi.zip; sudo bash d10pi.zip

This will download the installation program, add the 3CX repository to your APT repositories, and install the 3CX public key. When those are done, the installation program begins:

Select 3CX to install the on-premise solution.

Select “Ok” to accept the license agreement. The installation will proceed and you will see the following screen when it is complete.

Configure 3CX Installation

Choose 1 to run the configuration tool in your web browser. Navigate to the following address specified to begin the initial configuration wizard:

http://<ip address>:5015?v=2

When you see the installation wizard, input your license key from the link shown:

Create your credentials to log into your Management Console:

It will leverage a similar function as WhatIsMyIP to determine your current Public IP Address.

In my case, I have a dynamic IP address from my service provider.

You will next select the ports that your 3CX installation will use. I went with the defaults, but you can decide what is best for your environment.

The next step is where you specify a Fully Qualified Domain Name for your installation. In order to use the phone apps, your system must be accessible from the outside. I use Dyn.com for dynamic DNS services for my home network. You can also just go with an IP address. This will be used to generate the appropriate certificates for your installation.

The next option will be to decide upon a dialing plan. Even though I won’t have many numbers to support, I chose to use a 4-digit plan for my extensions. My plan is to use the same last 4 numbers as my cell phone number–makes it easy to set and remember the extensions.

Specify an email for your admin user. Mail notifications will be sent from your server, so this needs to be a valid email address.

Set the country and time zone for the installation.

The Operator Extension is the default extension for the system. In my case, I don’t use it for anything other than a placeholder.

You will need to choose which countries your phone system is allowed to dial. The drop-downs allow you to choose specific countries within the continents.

Select the language for the voice prompts. You can add additional languages after the installation is complete. This is the last step to configure your telephone exchange. When you click “Next”, the 3CX system will go through the rest of the initial configuration process.

That’s it! You now have a 3CX telephone switch running on a Raspberry Pi. Notice there is a 3cx.us address for the management console. This is a DNS entry managed by 3CX that will point back to your server. Use this link to manage the 3CX server.

Configure Firewall and Router

The last step to getting your 3CX system up and running is to allow outside connections through your firewall. I will be sharing additional posts on the specifics for my use case (I’ve ended up with 3 different configurations that I will share). For now, I’ll leave you with a link to the 3CX guide to configuring the firewall.

In my case, I opened ports 5090 (udp and tcp) for the 3CX tunnel and port 5001 (tcp) for the provisioning. I did not open port 443/tcp because that port is being used by another application in my stack right now. Since I do not plan to have any external VoIP phones and only use the iOS and Android apps, this is sufficient to allow me and my family to connect and dial each other.

That’s it for this one. Download the Apps on your phone to try the service out. The email you receive when you create a new extension will provide a QR code you can use to configure the app. Part 2 will go over configuring the service to work with the Amazon Chime Voice Connector.

Leave a Reply