Home PABX on an NSLU2

Vintage Blog from 12-Apr-2008

Find out about building a compact home PABX
Featuring a Linksys NSLU2, Cisco 79XX and Sipura SPA-3000

Always looking for a neat technical project to delve into, I recently decided to build an in-home PABX on the cheap. After I completed the project, I thought I'd better document what I did in case something broke down the track. With just a little more effort, I figured I could save others from having to reinvent the wheel by posting relevant information and links on my site. What you have below represents my trade-off between effort and functionality in documenting the project.

This page is not a step-by-step guide, but provides you with a big head start in finding the relevant resources. Anyone who is reasonably technical should have no problems. Just to be clear, some or all of the instructions on this page may void warranties or break your equipment.


Objectives:
  • Self-contained "appliance" solution
  • Solid State (no moving parts)
  • Relatively inexpensive parts
  • VoIP + PSTN capability
  • Least-cost routing of calls
  • Ability to "toll bypass" to other sites
  • DISA - Direct Inward System Access (Call in from outside, then call out using VoIP)
  • Voicemail including voicemail-to-email gateway

Hardware:
  • Linksys NSLU2 - A small appliance to act as the "server"
  • Kingston 2GB Data Traveler - 2GB USB memory stick to act as the "disk"
  • Sipura SPA-3000 - A way to connect to the PSTN and analogue phones
  • Cisco 7940 - A fully-featured VoIP phone that I got cheap on eBay
  • A generic cordless phone
  • Existing home network (DSL modem, router and switch)

Summary:
Documented below is the process I undertook to set up my in-home PABX. The heart of the system is a Linksys NSLU2 which is running Asterisk (SIP, IAX server, Voicemail server, etc.), TFTP Server to provision a Cisco 7940 and HTTP Server to provide services to the Cisco 7940. In addition I have a Sipura SPA-3000 to provide integration with Analogue services (analogue phone line and old analogue phone).
Initial Comments:
Before you embark on such a project, you should know that there are many ways to skin a cat. You can achieve most of the items listed in the Objectives section above with just the Sipura SPA-3000. In fact, the only thing you cannot achieve with just the SPA-3000 is the last item - voicemail. One solution to the voicemail issue is a simple answering machine (although you don't get the voicemail-to-email gateway). You should also realise that some features (DISA is the big one) can become a major security risk. If someone gets into your DISA system, they can make outgoing calls using your account - this could be an expensive problem. The benefits of going for the more complicated solution described below include the many features of a born-digital VoIP phone such as the Cisco 7940 as well as sophisticated call routing based on your own scripts.
Configuring the Linksys NSLU2 Server Hardware:
In order to meet my objective of a fully solid-state and small package, I decided to use the NSLU2 (which is normally meant to be a networked file-server) combined with a normal USB memory drive. In order to install Asterisk on a Linksys NSLU2, it needs to first be "Unslung." The NSLU2-Linux project has a great page describing exactly how to do this here. Because I am using a USB memory drive instead of a physical drive, I made some configuration changes to minimise unnecessary disk activity (which can wear out the USB memory stick). Instructions to do that are here. I also made some configuration changes to free up some additional memory on the NSLU2 - instructions here. It's also important to install SSH (linked instructions above) so that you have a way to connect to the NSLU2 and issue commands to it.

Although a stock NSLU2 is sufficient, I decided to overclock (or de-underclock) the NSLU2 using instructions here. It's really simple to do, I just opened the case and used a box-cutter to cut the relevant resistor off the board (no soldering required).

To make things easy, I recommend you install nano, a great text file editor/viewer. I will refer to it later.:

  • ipkg install nano

There is a vibrant community of people running modified NSLU2s, for more information check out these sites:


Installing Asterisk:
The most popular software for building home PABXes these days is Asterisk, so that's what I decided to use. The summary explanation for how to install Asterisk on the "unslung" NSLU2 is to type the following at the root prompt:

  • ipkg install asterisk
  • ipkg -force-overwrite install asterisk-sounds
The first line installs Asterisk, the second line installs the optional sounds package.

There are already many detailed guides out there on how to run Asterisk on an NSLU2, so I wont repeat them here, but here are some good links to detailed instructions.

In addition, there are some fantastic resources out there for all things Asterisk.
Configuring Asterisk:
In order for Asterisk to be useful, you need to get an account with one or more VSPs (Voice Service Provider). There are hundreds of them out there and voip-info.org is as good place as any to find one. I happen to use a few VSPs because each one has its pros and cons and Asterisk allows you to cleverly route calls to the best VSP for a particular call. The NSLU2-Asterisk Yahoo! Group (linked above) has downloadable sample .conf files to get you started. These should be stored in /opt/etc/asterisk/ on your NSLU2. The key files to configure first are:
  • extensions.conf - Your phones and service providors
  • sip.conf - How SIP calls are treated
  • voicemail.conf - Handling your voicemail
  • iax.conf - Same as sip.conf but for IAX protocol (optional)
The easiest way to get the files onto your NSLU2 is to just connect to its shared drive with your computer (the same way you connect to any Samba or Windows shared drive). If you have trouble dropping the files in the right directory, check that you have the right permissions set. (hint: look up the chmod function on Google). If you dont want to play with chmod then you can drop files into the /public/ directory, then SSH into the NSLU2 and move them using the Linux mv command.


Configuring the Sipura SPA-3000 & Analogue side:
The process of connecting an SPA-3000 to Asterisk to allow the use of a standard analogue phone and phone line is well-documented elsewhere and I wont try to repeat here. Suffice to say that Google will be your friend in doing this. Here are some shortcuts to some good "how to" guides.
Loading Asterisk for the first time:
You can try loading asterisk by typing /opt/sbin/asterisk -vvvc or /opt/sbin/asterisk if you want to run it as a daemon. By this point you should have a fully functioning system that you can use with any normal analogue phone. Although the use of an NSLU2 is unusual (most people probably use a real computer as an Asterisk server), there are still many people out there with a very similar configuration to the one described above.
Configuring the Cisco 7940: Part 1 - Basics
Once I had the working system described above, I next turned to trying to get a Cisco 7940 hooked up. This was much harder than I thought and therefore I will be more detailed in describing what I did.

I bought mine used on eBay for about AU$275 including power adapter. Make sure you get the power adapter because unlike home networks, in most corporate installations the power is supplied over the Ethernet cable using a technology known as PoE (Power over Ethernet). My phone came with no documentation and upon plugging it in, just sat there waiting to be provisioned while giving me a "Protocol Application Invalid" error. I couldn't even get to any sort of settings menu. I also found out that there are many different firmware versions for this phone and that not all of them support the SIP protocol which is what you need to easily interface with Asterisk.

One of the first things I learned is to reset the phone without unplugging it all the time. This is very useful because as you play with the configuration you will constantly be needing to reset the phone.

Rebooting a Cisco 7940

  • To reset / reboot the phone press the * 6 and settings buttons simultaneously
Another important trick I learned was how to reset the phone to its factory configuration.

Factory Reset a Cisco 7940

  • Hold down the # key while you boot the phone
  • After a second or two, the phone will display: Reset key sequence detected
  • The Headset, Mute, and Speaker lights will cycle
  • Press the following keys one at a time in order: 1 2 3 4 5 6 7 8 9 * 0 #
  • The phone will then prompt you Save network cfg? 1=yes 2=no
  • Press 2 for no
  • The phone will then display: Factory reset initiated and continue to boot

I also learned that the Cisco 7940 default password is cisco

The Cisco web site has a lot of documentation, but some of it is quite hard to read. Also, you will need to register on their web site to be able to download some of the documentation as well as the firmware / config files. To begin with, I would get the following documentation to keep as a handy reference:

There are also some good non-Cisco sites with information on the 7940:
Configuring the Cisco 7940: Part 2 - Preparing the NSLU2
When booting, the Cisco 7940 downloads its configuration files from a TFTP server. Conveniently, the NSLU2 has the capability to become a handly TFTP server using the tftpd package. To install it:
  • ipkg install tftp-hpa
Then check that /opt/etc/xinetd.conf has the following:

----------------------------------------------------

defaults
{
only_from = localhost 10.0.0.0/24
instances = 60
log_type = SYSLOG authpriv info
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}

includedir /opt/etc/xinetd.d

----------------------------------------------------

Note that the line "only_from" has 10.0.0.0/24 because all the IP addresses in my network are in the form 10.0.0.x. You may need to change this to suit your network (e.g. 192.168.1.0/24) Also check that /opt/etc/xinetd.d/tftp looks like this:

----------------------------------------------------

service tftp
{
flags = REUSE
socket_type = dgram
protocol = udp
instances = 30
wait = yes
user = root
server = /opt/sbin/in.tftpd
server_args = -vt 30 -s /opt/tftpboot
cps = 100 2
log_on_success = HOST PID
log_on_failure = HOST
disable = no
}

----------------------------------------------------

By the way, if you installed nano as I suggested at the beginning of the document, you can use it to easily view and edit these files. For example:

  • nano /opt/etc/xinetd.conf
You will notice that /opt/tftpboot/ is the base directory for the TFTP server. This is where all the files that the Cisco 7940 needs should go. Also, you will need to check that the file permissions are set right, otherwise the phone wont be able to pick them up. I use
  • chmod a+rwx /opt/tftpboot/*
but people more savvy than me would know if there is a better / safer way.

At this point you should probably test that the TFTP server works by placing a file in /opt/tftpboot/ and using a TFTP client to tftp to your NSLU2 to retrieve the file. The process will vary depending on what kind of computer you have, on my Mac I just type "tftp {NSLU IP ADDRESS}" and then "get {any filename}". If it doesn't work, you probably need to check your permissions. (Good 'ol chmod again).

Important: Do not proceed unless you have confirmed that your TFTP server is working.


Configuring the Cisco 7940: Part 3 - TFTP Settings
If you cannot access the Settings menu of your phone or your phone doesn't say "SIP" on the top right side of the display, or you don't know the password to your phone, you should skip down to Part 4 - Installing SIP Firmware.

We will now tell your Cisco 7940 where to find the TFTP server:

  • Press the settings button on the phone
  • Scroll down to Unlock Config and press Select
  • Enter your password - If you don't know it try cisco, otherwise skip to Part 4 - Installing SIP Firmware
  • Scroll to Network Configruation and press Select
  • Scroll to TFTP Server and press Edit and type in your NSLU2 IP address
  • Now would be a good time to check all the other settings as well
  • Exit back out of the settings menu and skip to Part 5 - The .cnf Files

Configuring the Cisco 7940: Part 4 - Installing SIP Firmware
First go through the factory reset procedure documented above in Part 1. Your freshly reset phone will now need to load its firmware from the TFTP server.

Because your phone doesn't know where the TFTP server is, you need to tell it via DHCP. This is a one-off step since once you have the firmware succesfully loaded, you can manually tell it where the TFTP server is. Therefore, the next step is to (temporarily) configure a DHCP server to give your phone an IP address and tell it where the TFTP server is. People who are a bit more clever than me would probably do it using the NSLU2 DHCP server (click here for more info) but I just used a little Windows program called MagikDHCP Server. MagikDHCP allows you to configure a DHCP server that sends out the address of a TFTP server. You should give it the IP address of your NSLU2 as the TFTP server and also make sure you remember to disconnect / disable any other DHCP servers on your network. Once you have the firmware loaded onto the phone, you don't need MagikDHCP anymore.

Next you need to download the SIP firmware from the Cisco web site. Cisco requires you to register in order to download the firmware. The version I got was 8.2 - although it may not be the newest version by the time you read this. The file is P0S3-08-2-00.zip. The Cisco website is a nightmare to navigate, but at the time, I was able to find the file by Googling around. The contents of P0S3-08-2-00.zip file are:

  • OS79XX.TXT
  • P0S3-08-2-00.loads
  • P0S3-08-2-00.sb2
  • P003-08-2-00.bin
  • P003-08-2-00.sbn
The OS79XX.TXT file is the first file loaded by the phone and simply contains the string P003-08-2-00 which tells the phone which firmware to load. In this case P003-08-2-00.bin and .sbin. If you have different .bin and .sbin files that you got from some other source, you could probably just change the OS79XX.TXT file to reflect this. I make no guarantees; however.

You will need to copy these 5 files to the /opt/tftpboot/ directory on the NSLU2. Make sure the file permissions are set properly with chmod and reboot the phone.

As a troubleshooting step if the phone doesn't find the files, check that you can manually GET the files using a TFTP client (see the instructions in previous section).


Configuring the Cisco 7940: Part 5 - The .cnf Files
In addition to the firmware files mentioned above, there are two configuration files that will need to go into the /opt/tftpboot/ directory.
  • SIPDefault.cnf
  • SIP{mac addr}.cnf - In my case SIP001460592D19.cnf, but each phone is different
These are the equivalend of the Asterisk .conf files and are used to provision the phone. The SIPDefault.cnf will provision all the Cisco 7940s on your network with standard values and the SIP{mac addr}.cnf is custom for each phone. (To find the MAC address of your phone, look at the middle sticker under the phone) Both files are text files.

You will need to make sure that the files are appropriately modified to match the settings of your particular configuration (Asterisk server address, usernames and passwords of the extensions in Asterisk, etc.)

Click on the two links below to see my sample files:

Copy the files to the /opt/tftpboot/ directory and make sure the file permissions are set properly with chmod.
Configuring the Cisco 7940: Part 6 - Success!
At this point you should be able to reboot your phone and it should pull the configuration information from the TFTP server on the NSLU2. If you set everything up correctly in the SIPDefault.cnf, SIP{mac addr}.cnf and your Asterisk .conf files, you should be able to make a call. This might be a good time to familiarise yourself some more with the setup by playing with some of the .cnf and .conf files. Also, once you have a working setup that you are happy with, it would also be a good time to make backup copies of everything in the following directories on the NSLU2:
  • /opt/tftpboot/
  • /opt/etc/asterisk/
Now it's time for some fun...
Fun with the Cisco 7940: Part 1 - Ring Tones
You will notice that in the Settings menu, option 2 lets you select the ring tone. In addition to the built-in tones, you can fully customise the tones. To install additional ring tones, simply copy the .pcm or .raw files to the /opt/tftpboot/ folder on the NSLU2 and add a simple text file called RINGLIST.DAT in which you provde the name (column 1) and filename (column 2) of the ring tone files.

This is a sample RINGLIST.DAT:

-------------------------------------------

Funny Tone 1 funny.pcm
Funny Tone 2 funny2.raw
Funny Tone 3 funny3.raw
Funny Tone 4 funny4.pcm
-------------------------------------------

Sample files (including a RINGLIST.DAT) can be found here:

  • Cisco 7940 Files - loligo.com
  • Other sites are now defunct and I've removed the links
If you want to make your own ring tones, you can find instructions here.
Fun with the Cisco 7940: Part 2 - Custom Logos
You can replace the big Cisco logo on the display with any other graphic. For example, on mine I am using the following image:

asterisk-tux.bmp

Doing this quite easy and involves adding (or modifying if it's already there) a line to the SIPDefault.cnf file.

  • logo_url: "http://www.webserver.com/path/file.bmp"
Cisco's documentation states that the logo should be a Windows Bitmap file (*.BMP) with 256 colors and 90 x 56 pixels in size. Once the image is created/acquired, place the *.BMP file on any web site available to you. Make sure you reboot the phone after you've made the changes.

The great thing about the NSLU2 is that it has its own built-in web server. So, all you have to do is place the file in the /home/httpd/html/ directory (make sure to set the file permission with chmod). This means you can point your logo_url: to http://Your_NSLU2_IP/file.bmp. In my case I made a sub-directory to keep the files separate from the Linksys default files.

These sites have some relevant files:


Fun with the Cisco 7940: Part 3 - Services
Your phone has its own built in browser which you can use to access external services. These are invoked by pressing the services button. There are several good sites out there that explain in great detail how to do this. In addition there are some pretty good tools out there to help you automate it all. Some of these tools require PHP which your NSLU2 can serve (check the NSLU2-Linux project for all the detail).

Check out the following sites for further information:


Fun with the Cisco 7940: Part 4 - Directories
When you push the directories button you have the option of accessing an external directory. This is simply an .XML file that you drop onto an accessible web server (again, the usefulness of the NSLU2 comes into play here since you can just stick it on the NSLU2 server just like you would for a Logo (see Part 2 - Custom Logo)). To configure it you specify a "directory_url:" in SIPDefault.cnf.
  • directory_url: "http://webserver.com/directory.xml"
The format of the .XML file is documented here on voip-info.org. I have also created an Excel spreadsheet that automates the process of creating the .XML file. Just download the spreadsheet and follow the instructions:
Fun with the Cisco 7940: Part 5 - Voicemail
Voicemail is a very easy function to configure. If you followed the instructions given at nslu2-linux.org then you are basically all set. When a message is left for the extension that the Cisco 7940 is registered to, the MWI (Message Waiting Indicator, a.k.a. the red LED on the handset) will turn on. It will automatically turn off when you retrieve the messages. If you want to be able to quickly access voicemail by pushing the messages button then specify the voicemail number in SIPDefault.cnf:
  • messages_uri: "88"
In my case, it is extension 88.


Version 1.14 12-April-2008
© 1987-2024