Bookmark Free VoIP Services!

The World??™s Best Asterisk Phone: And Now It??™s Plug-and-Play

22.04.2008 11:31 VoIP Asterisk - Source: nerdvittles.com

The World’s Best Asterisk Phone: And Now It’s Plug-and-Play

Filed under: — ward @ 2:00 am

A short while ago we proclaimed Aastra's 57i as the world's best Asterisk phone. And, with a huge helping hand from Aastra's technical engineers and documentation writers, we built a user interface for the phone (see inset below) with every imaginable feature to prove it. Well... every feature but one. We've always cringed when the commercial PBX vendors start bragging that their phones are plug-and-play while nothing in the open source world ever quite was, at least until today. What we mean by plug-and-play is that you take a SIP telephone out of the box, plug it into the network on which your Asterisk server is running, and boom. The phone just works. No configuring, no scrambling for manuals. It just works. The new extension number for the phone is created on your PBX, and it displays on the front of the phone when it boots. And, yes, folks can start calling you. Well, today Nerd Vittles is pleased to provide you with the software to make that happen at no cost at least if you're using Aastra telephones and a PBX in a Flash server. If you're using another brand of LAMP-compatible Asterisk server with FreePBX such as trixbox ce 2.x, then today's scripts should work for you as well. And, lest we forget, we want to express our special thanks to John Drolet, Aastra's VP of U.S. Sales for getting us some equipment for our test and development center. Others might call it a basement. And our usual accolades to Philippe Lindheimer, who heads up the FreePBX development team, for lots of hints and some sample code that we ended up not using. So... don't blame Philippe if this smokes! All of the "engineering" unfortunately is mine. So let's get started.

System Requirements. To make this fly, you'll obviously need some Aastra phones. Out of the box, this application supports the 57iCT, 57i, and 55i phones. You'll also need to add or turn on a couple of features that don't come enabled by default on PBX in a Flash systems. The first is a TFTP server which is used to hand out the firmware and application code to the Aastra phones. It doesn't really matter where the TFTP server is housed for this application, but we recommend your PBX in a Flash server to keep things simple. The second critical piece is a DHCP server which is used to hand out an IP address for each new phone as well as the IP address of the TFTP server to be used to load the firmware and configuration onto the virgin phone. I've been dying to use that word in a column! Where were we? The DHCP server must be running on your PBX in a Flash or LAMP-compatible server. We'll explain why in a minute. Third, you'll need our application code which does the heavy lifting to set up an extension in FreePBX for each new phone and then writes the configuration file necessary to actually set up the telephone instrument for use. All of our code is licensed for use under GPL2.

Installing TFTP Server and Aastra Config Files. The simplest way to get started with this project is to begin by reading our original article and following all of the steps there to install, activate, and populate the TFTP server on your system. Complete all of the steps down to the final section on Activating Your Phone. Be aware that our delivered aastra.cfg configuration was specifically designed for Aastra 57i and 57iCT phones. It also will work with Aastra 55i phones (which are only about $25 cheaper than the 57i's) although you'll need to make yourself a sticker to match the top third of the display shown in the 57i screenshot below. The 55i is missing this extra screen real estate. See the phone on the left above (55i) and compare it to the phone in the second row above (57i). There's plenty of documentation on Aastra's web site to walk you through further customization. Aastra models further down the food chain will require some major button reworking in aastra.cfg before the rest of this tutorial will be of much benefit. HINT: In case you haven't figured it out, this is NOT the place to save money on your new phone system.

Installing Plug-and-Play Application. Let's set up the application first. Just log into your PBX in a Flash server as root and issue the following commands:

cd /
wget http://pbxinaflash.net/scripts/plugplay.tgz
mv /etc/dhcpd.conf /etc/dhcpd.conf.bak
tar -zxvf plugplay.tgz
rm plugplay.tgz

Configuring Plug-and-Play Application. To configure the application for use, there are three steps. First, we'll set a few variables to match your system. Second, we'll protect any existing Aastra phones that already are in use on your network. And third, we'll set up a cron job to check for new phones each minute of your workday. We'll reserve the third step until after we get your DHCP server up and running.

To set the defaults for your system, edit /root/dhcp/settings.conf: nano -w /root/dhcp/settings.conf. The default settings look like this:

START_EXTENSION="701"
PW="1234"
HOST="192.168.0.50"
CALLGROUP="1"
PICKUPGROUP="1"

Much like a DHCP server, the START_EXTENSION variable is used to tell the application the beginning extension number to use in setting up new phones. Pick a starting number with lots of downstream numbers available because there is no error checking! For example, if you already have an extension 702 on your system and you set this up to begin handing out extensions starting with 701, that means the second new phone you add to your system will cause a royal mess. If you think the most phones you'll ever add is 20, then pick a block of 40 numbers and enter the starting number between the quotes for START_EXTENSION. In case you couldn't figure it out, PW is the default password for the new phone extensions that are created. Pick something secure especially if your Asterisk server is exposed to the public Internet. Once the phones are set up, the passwords can be changed in the usual way using FreePBX. For HOST, enter the IP address of your PBX in a Flash server to which your new phones will be connecting. If you use call groups and pickup groups, adjust these settings to meet your requirements. Otherwise, leave them alone. Save your settings by pressing Ctrl-X, then Y, then ENTER.

Protecting Existing Aastra Phones. This next step is extremely important if you have existing Aastra phones functioning on your system. To properly protect their configurations from being overwritten, let's first walk through how the new software works. A cron job kicks off a script every minute that looks in your DHCP leases table to see if your DHCP server has handed out any new IP addresses. If it has, the application checks to see if the MAC address associated with any of the new dynamic IP addresses matches the Aastra MAC address signature. If there is a match on one or more MAC addresses, then the script checks each MAC address to see if it is already registered as an Aastra phone on your system. The way it does this is by searching for the existence of a configuration file in /tftpboot that matches the MAC address, e.g. 00085D19C5D2.cfg is an Aastra phone on our system. If the file is found, the program exits without configuring the phone. So... for phones you wish to protect, be sure that you create a MAC address config file for each of them in /tftpboot on your server, e.g. touch /tftpboot/00085D19C5D2.cfg would do the trick.

The Rest of the Story. Now let's cover how the application works once it discovers that an IP address has been handed out to an "Aastra phone" for which a config file does not exist in /tftpboot. First, the software will generate a new extension in FreePBX to serve as the dedicated extension for this new phone. It does not activate voicemail for the new extension. You can edit any of the new extensions and activate voicemail if you need it for particular phones. Next, the software puts a reservation for this new IP address and phone in the DHCP config file. This assures that this phone will always get the same assigned IP address even though it is managed by your DHCP server. Finally, the software generates a MAC address-specific config file in /tftpboot matching up the new extension created in FreePBX to this new phone. Once this is completed, the phone is rebooted which forces a refresh of its setup using the settings. The whole process only takes a minute or so per phone including a firmware refresh. Your new phone now is ready for use. You can make calls and receive them. And the extension number of the new phone will be shown on the main display of the phone. If for some reason the process encounters a problem, you can force a new refresh of the phone by editing the MAC.cfg for the phone and adding something as insignificant as a blank line. Then restart the phone by pressing the Options or Tools button and choosing Restart Phone. We'll cover activation of the software after we get your DHCP server up and running.

Installing DHCP Server.PBX in a Flash is delivered with a DHCP server already installed but not activated. Before you activate it, let us provide a few preparatory tips. The design today assumes that you have a hardware-based firewall/router and that your PBX in a Flash system sits on the private network behind that firewall. If this is not the case with your setup, stop here. The rest of this won't work! If it is your situation, then the first step will be to disable any existing DHCP server on your private network. Having more than one active DHCP server on the same subnet is a very bad idea because IP addresses will be plucked from the different DHCP servers randomly, and you'll end up with a colossal mess.

Before disabling your existing DHCP server, a little housekeeping will save you a lot of headaches. Keep in mind that DHCP servers hand out "leased" IP addresses, i.e. a particular device gets the IP address for a fixed period of use. When half of that lease expires, the device will request a renewal. Thus, when you disable your existing DHCP server, all of that institutional knowledge about existing leases will disappear. One way to avoid the Humpty Dumpty Syndrome is to create "reservations" for existing leases. In essence, you are telling the DHCP server to remember a particular MAC address of a networked device and always hand out a specified IP address to that address. This address MUST be in the range of IP addresses being managed by the DHCP server.

So... Step #1 is to go to the web interface of your existing DHCP server and write down the device names, MAC addresses, and IP addresses of every existing device. Why? Because, if you don't hard-code these reservations into your new DHCP server, there will be no guarantee that the same IP addresses get handed out when the leased addresses come due for renewal. Failure to heed this advice may result in all sorts of quirky network issues once the lease times expire on existing devices. MORAL: It's easier than you think to hard-code existing reservations. Being lazy will only cause you heartburn in the hours and days ahead.

Step #2 is to read this simple tutorial about how your DHCP server works. In a nutshell, we're going to create a dhcpd.conf configuration file in the /etc directory on your server. In fact, the software install above did it for you. Here's the way ours looks:

ddns-update-style interim;
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {

# To start dhcp server: /etc/init.d/dhcpd start
# To activate on bootup: chkconfig --level 2345 dhcpd on
# chkconfig --level 016 dhcpd off

range 192.168.0.100 192.168.0.254;

option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.0.255;

option tftp-server-name "192.168.0.50";

# option nis-domain "domain.org";
# option domain-name "domain.org";
option domain-name-servers 192.168.0.1;

option time-offset -18000; # Eastern Standard Time
option ntp-servers 192.43.244.18;
# option netbios-name-servers 192.168.0.1;

default-lease-time 21600;
max-lease-time 43200;

# reserved IP addresses are next

host Kitchen-Mac {
hardware ethernet 00:1B:63:18:75:E8;
fixed-address 192.168.0.125;
}
host eeepc-toy {
hardware ethernet 00:15:AF:6C:1A:6B;
fixed-address 192.168.0.222;
}
}

Now let's edit the one we installed: nano -w /etc/dhcpd.conf. NOTE: If you already had a dhcpd.conf file, we renamed it to dhcpd.conf.bak. Not to worry! This looks harder than it actually is. Let's begin with the obvious. A # character at the beginning of a line is a comment. Be careful about curly braces. If they don't pair up, your DHCP server won't start. Go to the bottom of the file first. The last two sections between the braces (not including the closing }) are "reservations" for IP addresses you wish to preserve. Simply cut-and-paste a copy of this code for each reservation you wish to create. Be sure each reservation has a unique host name, a correct MAC address, and the fixed IP address you wish to hand out to this device. Don't use hostnames similar to the two examples because those names are used by this application. And remember that each of these fixed IP addresses must be in the range of addresses being hosted by your DHCP server.

Now, for the basics. The third line beginning with subnet is where you specify the subnet under which this DHCP server will be operating. In our example, the subnet is 192.168.0.0. For most home routers, you will either use this value or 192.168.1.0. Check your existing router/firewall to be sure or type ifconfig for some hints. The range line is used to specify the starting and ending IP addresses that the DHCP server is authorized to hand out. The subnet obviously must match. option routers is used to specify the IP address of your subnet router. With a hardware-based firewall/router, it's typically 192.168.0.1 or 192.168.1.1. option broadcast-address must match the subnet and usually has a last octet value of 255. For option tftp-server-name, enter the IP address of your PBX in a Flash server. This line works all the magic in telling Aastra phones where to go for firmware and config updates so be sure you have the IP address of your TFTP server entered correctly. For option domain-name-servers, enter the IP address of your firewall/router or the DNS server entries in your existing firewall/router. option time-offset is the Greenwich mean time offset for your time zone... in seconds. The option ntp-servers IP address should be okay. We've entered the IP address of time.nist.gov for you. The lease times also should be left alone.

Feel free to remove our two sample reservations. But DON'T REMOVE the line above: # reserved IP addresses are next. We use this commented placeholder to insert new reservations as phones are added to your system with this Plug-and-Play software. If you remove the commented line, then new reservations won't get added.

Once you get all of your settings entered, save the file: Ctrl-X, Y, then ENTER. To start your DHCP server (after turning off all existing DHCP servers), type /etc/init.d/dhcpd start. Assuming you don't get an error, go ahead and enter the following commands to make sure your DHCP server starts automatically when your server is rebooted:

chkconfig --level 2345 dhcpd on
chkconfig --level 016 dhcpd off

Loading Aastra Firmware into /tftpboot. For each Aastra phone model, there is a different piece of firmware. All of these should be unzipped and copied into /tftpboot on your server. The file names should look like these: 57iCT.st, 57i.st, and 55i.st. If you followed along in our original tutorial, you will already have the firmware in place for the 57i, 57iCT, and 55i. You can download firmware for additional Aastra phone models from here and the other phone-type links in the upper right panel of this page. Unlike some manufacturers, with Aastra, you'll want to download the current SIP firmware for each of your phone types. It's that good!

Activating the Plug-and-Play Software. To get things going, edit /etc/crontab (nano -w /etc/crontab) and add an entry to the bottom of the file that looks like the following. Adjust the 5-21 entry to reflect the hours of the day that you would like this application to run. It runs once a minute and uses virtually no processing power on your system so be generous with the hours.

* 5-21 * * * root /root/dhcp/scandhcp.php > /dev/null

Removing a Phone from Your System. Should you ever decide to remove a phone from your system that has been set up using this Plug-and-Play application, here are the steps to gracefully delete the information associated with this phone. First, use a web browser to access FreePBX and delete the extension associated with this phone. Choose apply config changes to reload FreePBX. Next delete the IP reservation in /etc/dhcpd.conf using your favorite editor. Then issue the command: /etc/init.d/dhcpd restart which will free up that IP address for future use. Finally, delete the MAC.cfg file associated with this phone in /tftpboot. Be sure to list the file to make sure you're deleting the correct one! Finally, issue the command: amportal restart to restart Asterisk. Enjoy!

Original text is here

www.sitename.com

  Add comment

Name: 
E-Mail: 
Comment: 
Enter code: