IT-LINUXMAKER, OpenSource, Tutorials

Asterisk on the Raspberry Pi

– an open, powerful alternative to the classic telephone system

Asterisk is free software that has been continuously developed since 1999 and provides the functionality of a full-fledged telephone system on virtually any computer platform. It supports IP telephony (VoIP) with various network protocols and, with additional hardware, can also be integrated with traditional telephone connections such as POTS (analog), ISDN basic access (BRI), or primary rate access (PRI, E1/T1). Originally developed by Mark Spencer at Digium, an active developer community has formed around Asterisk, contributing numerous extensions and applications. The name is derived from the English term for the star symbol ("asterisk").

Asterisk is available under a dual license: on the one hand under the GNU General Public License (GPL) as free software, and on the other hand under a proprietary license that allows its use in non-open, commercial projects.

Technically, Asterisk is primarily based on the SIP (Session Initiation Protocol) protocol to establish connections between end devices such as IP phones or softphones. Configuration is done via text-based configuration files, allowing for highly flexible, and if necessary, highly complex, customization. To facilitate this transition, graphical frontends such as FreePBX now exist, which visually implement many configuration tasks.

This how-to describes running an Asterisk server with FreePBX on a Raspberry Pi 4 Model B Rev 1.5. I myself have been reliably running a similar setup on a Raspberry Pi 3 Model B since 2020. My telephone system now runs on a Raspberry Pi 4 B.

My motivation for this goes back to 2010: I wanted to move away from the typical "black box" solutions offered by major telephone providers – such as Speedport, FritzBox, or Zyxel. These not only offer limited or poorly implemented firewall functions, but also lack any serious features in the area of ​​telephony infrastructure. Asterisk, on the other hand, can be quickly expanded into a powerful, flexible, and high-quality telephone system – even on inexpensive ARM-based hardware like the Raspberry Pi. 
Interestingly, many of these providers' routers are also based on ARM processors – albeit in a very limited and closed form. So why not use an open, freely configurable system?

Furthermore, my motivation for this extensive how-to is the obvious lack of instructions for installing Asterisk and FreePBX – especially on Raspberry Pi. There is a video project on YouTube from a service provider here in Germany, but in my opinion it's more entertaining than truly useful. Some of the videos are very long, and above all, there's no real structure for searching specifically for a setting. So, if you're looking for dial patterns, you might be lucky enough to just use the video filenames. Or if you want to know something specific about routing outgoing calls, you first have to sift through the sometimes unsorted videos. That's no fun. And that's also one reason why I'm not using installation videos here, but rather relying on screenshots. This lack of quick reference is another motivation for making this how-to available.

Important note on system architecture

However, using the Raspberry Pi as an Asterisk server brings with it a technical peculiarity that, if ignored, can lead to problems: Raspberry Pi models use an SD card as their primary storage medium ("hard drive"). And SD cards are simply not designed for systems with high or frequent write access.

Typical weaknesses of SD cards:

  • Limited number of write cycles per memory cell (NAND flash wear)
  • No or only very rudimentary wear leveling
  • No internal cache or RAM buffer
  • Standard file systems such as ext4 generate additional write load through logging

In particular, the /var directory tree, where many services store their log and spool files, is a critical factor. For Asterisk, this specifically applies to the /var/spool/asterisk directory, which contains the following, often write-intensive content:

  • Voicemails (voice messages)
  • Call recordings (e.g. via monitor())
  • Fax files (if fax function is used – which is increasingly irrelevant these days)
  • Temporary files for queues and call control
  • Spool files for outgoing calls

In my early Asterisk experiments, several SD cards failed while setting up the system – simply because of the massive write accesses.

External storage instead of SD wear and tear

The most reliable solution is to offload the /var directory tree (and ideally also /home) to an external USB hard drive or SSD. Starting with the Raspberry Pi 3, there's enough power available to reliably operate a USB hard drive—with a powerful power supply. This can easily be mounted as a separate file system. This not only protects the SD card from premature wear but also improves system stability and performance.

An Asterisk server on the Raspberry Pi is fully capable of managing over 100 SIP accounts (i.e., individual extensions or phone numbers) as well as multiple IAX2 links to external Asterisk servers. In practice, the Raspberry Pi only reaches its performance limits when there are several hundred simultaneously active connections – and then only if the voice traffic is actually routed through the server itself. In most cases, however, voice transmission occurs directly between the end devices (peer-to-peer), so the Pi only handles signaling, significantly reducing its load.

Special features and support

Before you begin the actual configuration, the Raspberry Pi itself must be prepared. Since both Asterisk and FreePBX were originally designed to run on systems with x86 and AMD64 architectures, some adaptation is required to make this software run on an ARM-based system like the Raspberry Pi.
This is where Ronald Raike's project provides valuable assistance. He provides a regularly maintained installation routine that significantly simplifies the installation and integration of Asterisk and FreePBX on the Raspberry Pi. This automation not only saves time but also avoids many of the typical pitfalls of compiling and setting up on the ARM platform.


IT-LINUXMAKER, OpenSource, IT-Support, IT-Consulting

© IT-LINUXMAKER 2025