If you were wondering how to configure Raspberry Pi to serve you as a GSM gateway, based on the free FreePBX solution, you’ve come to the right place. I will explain you step by step, in a short video, enriched with comments and illustrations, how to do it. I will also give you a list of necessary hardware and software.
Table of Contents
1) Required hardware and software
Below you will find a list of everything that I used to prepare our GSM gateway.
- Raspberry Pi 4 2GB RAM
- Power supply USB-C 3.1A
- 16GB MicroSD card
- MicroSD-USB adapter
- HDMI cable
- MicroHDMI-HDMI adapter
- ethernet patchcord
First, let’s plug in the microSD card and wipe the card using SDFormatter to remove all hidden partitions (if any exist).
Then install the RasPBX software using the Raspberry Pi Imager (using the “use custom” option).
Select from the list the device to which you want to upload the system.
After successful installation, let’s mount the card into our Raspberry.
Finally, we can connect all other components: USB modem, HDMI (using an adapter), network connection, power supply and a USB keyboard.
Under normal circumstances, it is enough to connect HDMI to the monitor. However, we will use the FullHD HDMI grabber to capture the image on our device.
Finally, we will see the system boot. After loading the image from the card, we will be able to log into the operating system.
2) Software installation and configuration
First, let’s log into the system. We can do it directly (keyboard + monitor) or by logging in using the SSH client. In both cases, the default login details are identical:
After logging in, we will see a list with some useful, ready-made scripts.
We will not write here about all security policies, time zone settings, GPIO ports, etc …
However, I recommend running at least the following commands:
- raspbx-upgrade – updating packages
- passwd – changing the default password
- raspi-config → System options → Expand Filesystem – expansion of the partition to it’s maximum card size (by default, the system is installed on very truncated partitions to fit on small microSD cards)
We can now execute the main command, which will install support for our USB modems:
During the installation, we will be asked for some information:
- Please enter the phone number of your SIM card – SIM card phone number (default +1234567890, can be changed later)
- Send incoming SMS to email address – enter your e-mail address if you want to redirect incoming text messages to it
- Forward incoming SMS to mobile phone number (via dongle0) – enter the number, if you want to redirect incoming SMSes to it (using this modem)
- Would you like to install a webpage for sending SMS with chan_dongle (y/N) – Should it create a simple website for sending SMS?
- Enter password for SMS page – If so, enter the password to access the site
Generally speaking, the script will guide you through the installation of
usb-modeswitch-data, etc … and add to the dialplan (files
/etc/asterisk/dongle.conf) sample context for handling our modem.
For the device to be properly detected, we recommend restarting the device.
After restart, we can check if our modem has been correctly detected in our system.
ls -l /dev/tty*
We should see three USB devices signed as /dev/ttyUSBx, belonging to the
To verify the modem status, we can do the following in the console (
dongle show device state dongle0
The state should be ‘
Free‘ (waiting for connections) and ‘
Registered‘ (registered to the operator).
And that’s all! The device is ready!
However, there is still a lot of work ahead of you. The activities worth starting with could include:
- FreePBX configuration (enter the device’s IP address in the browser)
- Asterisk protection (fail2ban, TLS, iptables, SIP configuration, PJSIP, etc …)
- review of documentation and available commands (http://www.raspberry-asterisk.org/documentation/)
If you would like to monitor everything that is happening on your PBX, try our own VOIPERO software.
The system arleady has started and now is completely FREE. Setup takes a few minutes.
Get to know what VOIPERO system is able to do in terms of reporting and live monitoring of VoIP systems based on Asterisk.