How To: Building an Embedded Asterisk PBX

Photo of author

Tim Higgins


Astlinux is a bundled distribution of the Asterisk open source iPBX private branch exchange (PBX) software and a Linux operating system. Originally developed by Mark Spencer at Digium, Asterisk is the leading open source software in the telephony/VoIP space. Asterisk excels at combining traditional TDM telephony capability – provided through hardware from Digium and others – with VOIP services. These include call routing, media gateway, media server and SIP signaling capabilities.

Asterisk in a small, quiet package

Asterisk in a small, quiet package

The Asterisk user community has been growing tremendously over the past two years, especially since the v1.0 release in the fall of 2004. With that growth has come the development of new distributions that bundle suites of software tools, to ease the setup and administration of a new Asterisk system. Asterisk@Home and Xorcom Rapid are both fine examples of this sort of activity.

Astlinux was developed by Kristian Kielhofner, and intended to go in a fundamentally different direction. Astlinux provides an Asterisk installation on a Linux distribution that has been built from scratch and optimized for small format hardware platforms – it takes what is essentially an embedded systems approach to Linux and Asterisk. In this article, I’ll show you how to build an VoIP PBX using Astlinux and a Soekris Net4801 single board computer (SBC).


Working largely on his own, Kristian has gone to great lengths to get the combination of the OS and Asterisk down to a mere 26 MB boot image. This opens up many possibilities in the design of the hardware, such as booting from small compact flash cards or USB memory keys.

While keeping the size of the system to a minimum, Astlinux includes the following features:

  • Linux kernel
  • dnsmasq
  • watchdog (busybox)
  • ssmtp
  • cron (busybox)
  • bash
  • busybox (and everything with it…)
  • TFTP server
  • vsftpd server
  • mini_httpd (with SSL)
  • PHP in CGI mode (patched for above)
  • OpenSSH
  • OpenSSL
  • NTP (ntpdate, ntpq, ntpd)
  • syslog (busybox with remote log support)
  • vi (from busybox)
  • tc (kernel traffic shaping)
  • iptables
  • phpconfig-like Asterisk GUI
  • Asterisk
  • AstShape, a QoS/traffic shaping script
  • rsync
  • nfs-utils (kernel modules and userspace tools for NFS support)
  • Sangoma WanPIPE driver use with Sangoma T-1 hardware
  • Zaptel drivers for Digium TDM hardware
  • working ztdummy (zaptel timing source without zaptel hardware)
  • libpri
  • Asterisk Manager Proxy

Don’t be too worried if some of these don’t mean anything to you. Astlinux is focused on providing only those things in the OS that are necessary to support the normal operation and administration of Asterisk. For example, email support is provided so that voicemail messages can be forwarded via email like any normal Asterisk installation. The inclusion of ztdummy allows for both MeetMe conferencing and music-on-hold, without requiring a Digium card for a hardware timebase reference.

While the list of required supporting services may appear long, the idea is very simple – create a very small Linux and Asterisk installation that supports common telephony hardware, and once configured, behaves like an appliance.

Choosing Hardware

Astlinux is available in several versions, each of which targets a different hardware platform.

I am familiar with the Soekris single board computer hardware, having previously used the excellent open source m0n0wall router on a Soekris Net4501 system. Thus, for this review, I chose the version compiled for the Soekris Net4801 single board computer. This SBC is based upon a National Semiconductor Geode SC1100 processor, which is essentially a 266 MHz 486 class processor. In addition, the Net4801 provides the following hardware features:

  • 256 MB SDRAM, soldered on board
  • 4 Mbit BIOS/BOOT Flash
  • CompactFlash Type I/II socket, 8 MByte Flash to 4 GByte Microdrive
  • UltraDMA/33 interface with 44 pin connector for 2.5″ Hard Drive
  • Three 10/100 Mbit Ethernet ports (RJ-45)
  • Two Serial ports (DB9 and 10-pin header)
  • USB 1.1 interface
  • Power LED, Activity LED, Error LED
  • Mini-PCI type III socket
  • PCI Slot, right angle, 3.3V signaling only

When ordered with a suitable case and power supply, the completed system costs around $260.

Soekris Net4801, CF card, USB key & power supply

Figure 1: Soekris Net4801, CF card, USB key & power supply

The Net4801 card is very small, and even the switching power supply is tiny. While the Net4801 supports an IDE hard drive, for this project the system will boot from a CF card, so it will have literally no moving parts. Since the system is destined for my home office, the fact that it is dead silent is a significant benefit.

In my earlier Asterisk installation, I had been using a Digium TDM-400p card to provide two analog line interfaces (FXO ports) to bring my lines from the telephone company into the Asterisk server. However, the basic case offered by Soekris Engineering does not provide sufficient space to fit a PCI card such as the TDM-400p.

Soekris Net4801 and Digium TDM-400 card with 2 FXO ports

Figure 2: Soekris Net4801 and Digium TDM-400 card with 2 FXO ports.

Note that the card will not fit into the case.

Soekris does provide cases that will hold the Net4801 and multi-port LAN cards. In fact, they even offer a bundle combining the Net4801 with a Sangoma T-1 card, a suitable case and power supply. But for my home office, a T-1 interface supporting 24 lines is overkill.

For this new installation I have decided that instead of using the TDM-400p card, I will simply call forward the analog lines to a phone number that is provided over IP from an online service provider. This way, if ever I have trouble with Astlinux, I can defeat the call forwarding and answer the main line using a plain vanilla analog phone that I keep on hand for just such an emergency. Given this strategy, the TDM-400p card is not required, which means the smallest, most basic case is adequate for this installation.

Base Operating System Configuration

Essentially all of the basic configuration of the OS can be accomplished by editing /etc/rc.conf, which is referenced at boot time to establish many operational settings. If you’re using Astlinux as your router, then the setup options for PPPoE, IP address, net mask, DHCP, DNS, NTP and traffic shaping are all in this one file. Early in my experiments with Asterisk, I used vi to edit config files by hand; I’m now in the habit of editing the config files from my Windows desktop using SSH and SFTP clients. The base config in rc.conf can easily be handled using either approach.

Astlinux provides two basic operating modes: one in which it provides a bundled routing and firewall solution, and a second “Asterisk-Only” mode that disables the router and firewall functions. The mode is selected through the use of the variable INTIF in the file /etc/rc.conf. If this variable is defined, then the system starts all the services necessary to support the routing and firewall capabilities; if it’s removed or remarked out, then these services are not started. The core services of SSH, HHTPd, NTPd, FTP, TFTP and of course Asterisk itself always remain fully functional.

Astlinux versions prior to 0.29 default to enabling the router and firewall capability, while from 0.29 onward the default configuration is the Asterisk-Only mode. This change in default reflects the fact that Kristian listens closely to the user community. Non-technical users will find that the firewall and router included along side the Asterisk installation provide an efficient bundle of capabilities with minimal hardware and administrative requirements. More technical users typically find that they need deeper or more convenient administrative control of the firewall.

The heart of Astlinux routing capabilities is the Linux iptables firewall. The basic setup of the router is established in /etc/rc.conf through the following variables:

When IP set via DHCP from ISP:
EXTIF=eth0 #defines the physical Ethernet interface
INTIF=eth1 #enables the router & firewall
[email protected] #PPP username for your ISP
PPPOEPASS=”mypassword” #PPP password
INTIP= #IP address of the internal NIC
INTNM= #Netmask for internal LAN
DOMAIN=”astlinux” #Domain name for the server
HOSTNAME=”pbx” #Hostname for the server
When IP is static: #setting that should be rem’d out when EXTIP set via DHCP
EXTIP=”your.ip.address.x” #External IP address presented to ISP
EXTNM=”″ #External netmask
EXTGW=”” #External default gateway
DNS=”your.isps.dns.svr” #DNS server

Quality Of Service

In Astlinux, the author makes no attempt to provide a user interface to iptables. He does, however, provide a traffic shaping script for iptables, which provides a routing and firewall solution with a “quality of service” (QoS) scheme designed to address the VoIP application. Management of network QoS is critical in any VoIP installation, as the voice packets must receive top priority network passage; otherwise, phone calls will cough and stutter unacceptably.

The QoS scheme is based upon the following two configuration variables in /etc/rc.conf:

EXTUP=”540″ #90% of the measured upload speed in kbps
EXTDOWN=”2200″ #90% of the measured download speed in kbps

The QoS scheme in Astlinux is based upon the “DiffServ” standard. This involves setting a “type of service” priority tag in all IP traffic. Routers can then assign priority to packets by evaluating the tags present in the data streams. The Astlinux QoS script works in conjunction with the Asterisk configurations to pass at the highest priority all traffic with the QoS tag set to tos=0x18.This is established in the Asterisk config files SIP.CONF and IAX.CONF. The 0x18 setting denotes “low delay” and “high throughput.”

In practice, QoS is especially critical on asymmetrical data circuits such as my ADSL service. Without careful QoS management, any uploads (such as FTP) that were going on could completely consume the available outbound bandwidth. If this occurred, then any call would sound crackly and broken up to the other party. With QoS correctly managed, the data rate available to the FTP upload is automatically slowed down when a call occurs, and the other party never knows that I use an IP based phone system at all.

For more details about QoS please visit the VoIP Wiki.

In my office, I decided to stick with my trusty m0nowall router running on a Soekris Net4501. As such, I kept Astlinux in Asterisk-only mode and beyond some simple testing, did not make use of its routing or QoS capabilities.

Booting From Compact Flash

Unlike hard drives, there are very real limits to how many read/write cycles a compact flash (CF) card can survive. If the system was to treat the CF card just like a hard drive, then the CF card would fail in an unacceptably short period of time. On the Asterisk Users Mailing List, I found users whose experience was that the point of failure can be as low as 300,000 writes, even when using high quality, brand name CF cards.

Astlinux has been designed to get around this issue through use of a RAM disk and by limiting write access to the CF card. At boot time the contents of the CF card are copied to a RAM disk, which is then used to boot the OS, services and applications. The CF is still mounted by the OS, but in read-only mode. Symbolic links are used to provide pointers on the RAM disk to critical config files on the CF card, and all disk writes happen to/from the RAM disk. This approach extends the service life of the CF card by several orders of magnitude.

Here’s my experience. My initial Astlinux test system used an old generic 128 MB CF card once used in a long dead digital camera. That card was in service for more than a year without any problems at all. For my new Soekris based production Astlinux system I purchased a new 32 MB Sandisk CF card for a mere $8 on eBay. Kristian recommends Sandisk cards, as he has found them to be the most reliable.

Windows installer writing the Astlinux boot image to a CF card

Figure 3: Windows installer writing the Astlinux boot image to a CF card

Since I’m no Linux wizard I needed to load the CF card with the boot image using my Windows XP desktop. The Windows installer for Astlinux includes a utility called “physdiskwrite” for loading the CF card on any PC with a suitable media reader. Writing Astlinux to the CF card was easy (Figure 3) and took less than 2 minutes.

Asterisk User Configuration

Upon initial boot up there is a generic, fully functional Asterisk configuration loaded. This is sufficient for simple testing of Asterisk, but you will very quickly feel the need to amend the configuration to suit your own purposes. This is accomplished through loading your own Asterisk configs, which are not part of the CF boot image. Since the Soekris board provides a USB port, the easiest approach is to use a small USB key drive to hold the user-defined config files. Astlinux provides a simple command line utility for setting this up.

Typing genkd at the console invokes a shell script that formats the USB key and places default config files in the correct locations on it. After a quick reboot, the system uses symbolic links to read the Asterisk config files from the USB key instead of the CF card. The USB key also becomes the storage location for any incoming voicemail messages.

Since the USB key is easily swapped, this approach lends itself especially well to experimenting with various Asterisk configurations – moving between them is as simple as changing keys and rebooting. It’s easy to see how this could be valuable to a telecom consultant for example, who could program complex dial plan logic or interactive voice response systems, then simply move the USB key to a production server to deliver the working system.

In reality, the choice of a USB key is a matter of convenience; you could elect to use an internal or external hard drive or even an NFS share. If you are using the generic 586 boot image of Astlinux on CD you could have the server boot to CD and store configs and voice mail on essentially any form of local media.

SSH client logged into the Astlinux server

Figure 4: SSH client logged into the Astlinux server

Once the basic system was up and running with a USB key as local config storage, my next task was to get my existing configs moved from the old server to the Soekris system. As is my habit, I used an SSH client to log into the old system from my Windows desktop. My SSH program of choice ( includes SFTP capability, which I used to copy the contents of /etc/asterisk/ to a folder on my PC desktop. I then logged off the old system and logged into the new one, put all the configs into /etc/asterisk/, and rebooted the Soekris system from the command line.

While I use Private Shell, the freeware PUTTY suite of programs provides both SSH and SFTP clients that could also be used in this manner.

SFTP client logged into Astlinux, viewing a file list of /etc/asterisk/

Figure 5: SFTP client logged into Astlinux, viewing a file list of /etc/asterisk/

Many IP phones rely upon some form of central provisioning scheme. The Polycom & Aastra phones that I presently use can be configured to load their firmware and configuration from a local FTP or TFTP server. Happily, Astlinux provided both of these by default, so all I had to do was set the phones to use FTP and give them suitable login credentials. The root directories for these services are also symbolic links to a folder on the USB key drive.

Astlinux also provides an NTP client and server pair. Upon booting, it seeks an Internet NTP server from, then provides an NTP service to devices on the local LAN. This is a very convenient way to ensure that all of your phones and call records have matching time and date settings.

CPU Limitations

Naturally, there are limits imposed by the available CPU power on these sorts of small format systems. It is generally accepted that Asterisk requires about 30 MHz of CPU power per active voice channel. Thus the 266 MHz CPU on the Net4801, in theory, supports around eight simultaneous calls. This presumes that all calls are G.711 encoded audio; G.711 is the encoding scheme most commonly used by telcos in providing traditional land lines. When combined with IP overhead, G.711 requires around 80 kbps in each direction per call leg. Thus, passing ten calls to our Internet Telephony Service Provider (ITSP) requires a theoretical total of 800 kbps of bandwidth for both inbound and outbound data.

Sometimes it is desirable to limit or reduce the VoIP bandwidth requirements. In my case, my ADSL service is 2.2 Mbps download and 768kbps upload. With this sort of connectivity it’s unlikely that I could pass more than five or six G.711 encoded calls at the same time. Thus, if I needed to maximize my call capacity I’d need to use a more advanced voice compression scheme such as G.729a encoding.

Codecs for G.729a compression are not available open source, and thus are not part of the Asterisk or Astlinux base installations. Licenses are commercially available from Digium for $10 USD per stream. Using G.729a on each leg of the call allows it to be compressed down to <10 kbps of data, but real-time compression is a very CPU intensive task. The SC1100 CPU on the Net4801 will only successfully encode two streams of voice using G.729a compression.

There are other voice compression standards, such as GSM, G.723, iLBC and SPEEX. These generally trade compression efficiency against latency, CPU requirements and voice quality. None are as widely accepted by ITSPs as G.711a/u and G.729a.

Again, considering the SOHO/small business nature of the target users for Astlinux, these limitations are probably not significant. It certainly doesn’t impact my use of the system in my full time home office, even with four incoming lines. Of course, more demanding installations could run the generic 586 version of Astlinux on a more powerful hardware platform, to avoid being CPU limited.

Asterisk Administration

Asterisk has a well-earned reputation for being complex to setup and administer. Graphical management overlays often add to the actual complexity of the installation, in their attempt to shield users from the system internals.

Astlinux takes only small steps in the GUI direction, providing by default a Web-based administration portal at Note that this is a private IP address; the Web page is secured by default and only available on the LAN side of the device.

The Web-based administration GUI provides pages for examining the Asterisk configuration, accessing the Asterisk command line, listing the FTP root directory, and looking at the call history log (see Figure 6).

Asterisk Call Log

Figure 6: Asterisk Call Log

You can also load a general status page (Figure 7), access ping and tracert utilities, and access the Linux shell.

Server Status

Figure 7: Server Status

Finally, there is also a General setup page (Figure 8) with functions such as reboot, reload Asterisk settings, back up key files, etc.

General Setup

Figure 8: General Setup

In exposing the various config files via a Web-based presentation, these pages provide enough to get a beginner started without forcing them to learn the vi editor. However, users will still probably need to edit config files directly.

In Use

In practice, I found that core PBX performance was solid. Internal calling, voicemail, hold, transfer, music-on-hold and conferencing all worked as I’d hoped they would. I rely upon several different service providers to handle incoming calls (including an 800 number) and outgoing call termination. All of my existing accounts worked immediately.

Note that all the phones and ITSP accounts were set to use G.711a audio, so no transcoding was required. This is especially important if I want to host MeetMe conferences, as the Soekris system doesn’t have the CPU power to transcode and mix several streams at once.

Similarly, Astlinux provides a modified Music-on-hold capability that relies upon the availability of music clips prepared in the compression scheme in use at the moment. In my case that was G.711a. This is in contrast to a more general Asterisk installation, which uses the third party open source MPG123 utility to on-the-fly transcode MP3 files into whatever audio encoding scheme is in use on a particular call. The Astlinux distribution includes several clips in the G.711 and GSM formats. Instructions for preparing other music clips were easily found in the VoIP wiki at

Perhaps one of the greatest attractions of Astlinux, when compared to a more typical Asterisk installation, is that the PBX application and the host OS and drivers are bundled in the Astlinux software release. This effectively eliminates the need to establish separate maintenance cycles for Fedora Core, Asterisk, MPG123, and the other drivers upon which the installation depends. If you’re not a Linux wizard this can also improve the reliability of the upgrade process, as you don’t have to address each of the software pieces individually.

The upgrade process for Astlinux itself is very straightforward. Major upgrades require writing a new boot image to the CF card, while minor upgrades are performed at the command prompt using the astup script. This script accesses the server at to update all of the software on the system in one quick step that takes just a few minutes; it has made it a simple matter to update the system on a weekly basis.

Of course, the Astlinux distribution includes documentation. The ten-page manual provides a good overview of the philosophy behind the project, information on getting through the initial installation, and options for booting from various devices.

A vibrant and active user community has also grown up around Asterisk. The Asterisk-Users mailing list often passes over 300 messages per day among its readership of well over 10,000. Additionally, Kris Companies has provided a similar mailing list for Astlinux; while not nearly as heavily trafficked, it is active and Kristian himself is usually available to address detailed issues at length.

Between the manual, the two mailing lists and the VoIP wiki at I have never felt that support was lacking. With just a little investigation I’ve been able to overcome every issue that has arisen, and gained something of an education along the way.

Closing Thoughts

Most of my experience with Astlinux on the Soekris platform has been with using version 0.28, which is based upon a very stable Asterisk v1.09 release from Jan 10, 2005. Kristian released version 0.29 recently, which encompasses the newer Asterisk v1.2 release from October 2005. By the time you read this review, Kristian may well be on release v0.30, which is projected to be a thoroughly tested Astlinux implementation including Asterisk v1.2 and support for some new hardware drivers. However, changes in Asterisk’s core dial plan logic behavior kept me from trying the new release within the context of this review.

Kristian also made news at Astricon 2005 by successfully porting Astlinux to the Gumstix embedded SBC platform. Called TinyPBX, this combination was heralded as the “World’s Smallest VoIP PBX.”

The initial application of such a small Asterisk system was as a protocol translator, allowing common SIP desk phones to be easily adapted to use the IAX2 protocol native to Asterisk. Unlike SIP, IAX2 streams combine call setup signaling and the voice data stream into a single connection that easily traverses NAT routers and firewalls. The combination of a Gumstix based translator with SIP desk phones allows for the creation of distributed phone systems ideal for companies with many home office based employees, or for connecting several smaller offices into one primary Asterisk server. Using IAX2 instead of SIP permits this with a minimum of network setup and support complexity.

Astlinux has proven to be a valuable tool around my home office. It provides the power and flexibility of an Asterisk installation with the reliability and simplicity of an embedded system. It may not provide the comfort of a graphical administration scheme, but it suffers none of the overhead or setup limitations of common GUI overlays.

The Soekris Net4801, while inexpensive, has been absolutely reliable as a host platform, delivering adequate processing power to support six extensions and up to four active lines at one time. It could perhaps do more, but such was beyond the scope of my ability to test.

Together, Astlinux and the Soekris Net4801 represent an elegant D.I.Y. approach to deploying an iPBX in a home or small office setting.

Related posts

Diary Of My Switch To Internet TV – Part 10 – Internet TV Boxes? Bah, Humbug!

Looking for the perfect box this holiday season to help cut the cable? Get a computer.

Hacking the Apple TV

With some fairly simple hacking, Jim Buzbee turns the Apple TV into the best media player he's seen yet.

Eyes On Everywhere

How do you get video eyes on a spot too far for a Wi-Fi camera and beyond cable reach?