Search in Blogs of Narayana Rao

Loading

Monday, July 11, 2011

PBX in a Flash by Ward Mundy

Source Knol: PBX in a Flash

by Ward Mundy, Housekeeper, Atlanta, GA
Last updated 6 October 2010

We're pleased to introduce version 1.7.5.5 of PBX in a Flash in this Knol™. This version is chock full of new telephony goodies to whet your appetite for Internet Telephony. Tom King has worked his usual Magic™ to come up with a pair of new ISOs that are nothing short of spectacular. Not only is PBX in a Flash leaner and meaner, but it's now incredibly flexible. You don't get the kitchen sink in PBX in a Flash ISOs. Instead you get a rock-solid CentOS™ 5.5 operating system on which to build an Internet telephony server that meets your specific needs. Want a 64-bit operating system? We've got it. Prefer to stick with a 32-bit operating system? We've got you covered there, too. Want to experiment with Asterisk™ 1.6? We've got it. Want to stick with Asterisk 1.4 for a production environment? We've got you covered. Do you prefer LVM, ext3, or SATA RAID for your disk drives? Well, take your pick. PBX in a Flash 1.7.5.5 now supports all of them. For those with a physical handicap, you now can install the complete system with no user intervention by typing ksauto at the first prompt. And, for PBX in a Flash development partners, we've even designed a 2-CD install set that makes production of multiple systems with minimal Internet access a reality.

A Better Mousetrap
Asterisk-based LAMP (Linux™, Apache™, MySQL™, PHP™) aggregations, of course, are plentiful today, but we think we have a better mousetrap. Here are a few reasons why? First, PBX in a Flash is the only distribution that is totally source-based with Asterisk compiled from source. What that means is when you purchase add-on hardware and it has a problem for some reason, all of the tools are already in place for you to contact the manufacturer or reseller and have them reconfigure or recompile whatever is necessary on your system to get you back in business quickly. It also means that most of our applications are compiled from source on your specific hardware which assures a more reliable and stable software platform on which to build your telephony system.

Second, we don't release PBX in a Flash ISOs every other week. We don't have to. Every time a new security patch is released for Asterisk, the "other guys" have to create a new RPM or ISO to support it. That means your system is vulnerable while this process is underway. In many cases, it means reinstalling a new ISO and starting over. I wish I had a nickel for every time I reinstalled and basically started over with Asterisk@Home or trixbox™ . With PBX in a Flash, you simply type update-source at the command prompt and your system is brought current without missing a beat. The total downtime for your system is typically under 15 minutes!

Third, PBX in a Flash uses a two-step install process that all but eliminates the ISO obsolescence issues that have plagued other distributions. The PBX in a Flash ISO is used to install either the 32-bit or the 64-bit CentOS 5.5 operating system. When that process completes, the installer then searches multiple sites on the Internet for our "payload files" which contain the latest, greatest versions of Asterisk, each of which is compiled on-the-fly. You have your choice of PIAF-GOLD with Asterisk 1.4.21.2 and zaptel, PIAF-SILVER with the very latest version of Asterisk 1.4 and DAHDI, PIAF-BRONZE with the latest release of Asterisk 1.6.2 and DAHDI, or PIAF-PURPLE with the current beta release of Asterisk 1.8. The payload scripts also install FreePBX 2.6 and many of the customized features that make PBX in a Flash unique. If you need additional functionality, we have an entire web site, pbxinaflash.org, dedicated to add-on scripts. And, by the way, our typical add-on script installs without user intervention in under a minute. So... install what you need and skip the BloatWare. Using this design, most bugs are eliminated as well without your having to do much of anything. Translation: More siesta time. Less all-nighters!

Here's another reason that all of this matters. This is a true story that will give you a good handle on the flexibility that our design strategy brings to the table. We introduced a prior version of PBX in a Flash to our loyal fan club and, within an hour after its release, the Asterisk Development Team announced a security patch and distributed new versions of Asterisk 1.4 and 1.6. Tom King, who was responsible for development of our latest payload files, happened to be scuba diving in the Atlantic Ocean as all of this unfolded. We sent him a text message to alert him to the problem. When Tom came up for some fresh air, he got the message. Then, using a cellphone from his boat, he kicked off an update script that regenerated all of the payload files with the latest Asterisk 1.4 and 1.6 security patches. And 90 minutes after the Asterisk security announcement, new PBX in a Flash installs included both new versions of Asterisk. For those that installed their systems within the first 90 minutes, update-source did the trick.

So today we're proud to introduce the 1.7.5.5 release of PBX in a Flash for Linux™, Windows™, and Macs™. It's still the Lean, Mean Asterisk Machine designed to meet the needs of hobbyists as well as business users. Text-to-speech works, Bluetooth™ works, FreePBX™ 2.6 is rock-solid, the platform is open, and there already are custom install scripts for both Asterisk 1.4 and Asterisk 1.6.2 with many more just around the corner. And the experimental Asterisk 1.8 version includes the experimental FreePBX 2.8 for our pioneers.

As some of our regular readers know, we have been very concerned with the Asterisk development strategy that continues the process of regularly deleting commands and syntaxes with each major version change. Many of us rely upon these commands in building dialplans and vertical market applications for Asterisk so it causes a mess. PBX systems break that used to work. When that happens almost annually, it's a bad thing. One way that we hope to improve the dialogue with the developers is to make it easy for more people to experiment with Asterisk 1.8. Whether you choose our 32-bit or 64-bit ISO, you also have the option to install the latest Asterisk 1.8 beta and get involved in the process. Otherwise, we might as well look forward to annual train wrecks because the developers and Digium don't appear to be budging from their design strategy. You can read all about it here and here. We'll have more to say about it in coming weeks. For today, we're going to keep our sense of humor and walk you through the typical installation scenario to bring up a new PBX in a Flash 1.4 system with the latest version of Asterisk 1.4. When we're finished, you'll have a rock-solid telephony system to begin your Asterisk adventure. So let's get started.

Getting Started with PBX in a Flash 1.7.5.5
Begin by downloading either the 32-bit or 64-bit ISO image for PBX in a Flash. Don't worry. If you try to run the 64-bit install on a system that doesn't support it, it'll just sit there so you've got nothing to lose by trying the Ferrari first. As new locations for ISO downloads come on line, we will add them to the download list. If you have newer hardware such as an Intel Atom-based system, this new release with CentOS 5.5 is perfect with much better support for newer motherboards and network adapters. Once you've got the ISO image in hand, use your favorite tool to burn it to a bootable CD. This next step is the most important. Don't begin your installation until you first download and read Tom King's Installation Guide. It's an easy, non-technical read and will condense the install process to about 30 minutes. There also are loads of other helpful tutorials that are free for the downloading from our support site.

If you're new to all of this, let us recommend you try the Acer Aspire Revo which is available from your favorite retailer for under $200. This system is just about perfect for a home or small business telephony server. And it's much less expensive to operate as well as being environmentally friendly. You will need an external CD/DVD drive as the Revo does not have one internally. We recommend HP and Sony USB drives which work well with CentOS 5.5. Make sure the system clock is set correctly on your machine before beginning. Then, just insert the CD containing the pbxinaflash.iso and then reboot the machine you wish to dedicate to PBX in a Flash. After reading Tom's tutorial and the initial prompts and warnings, press the to begin the installation. Choose your default keyboard and time zone and leave the UTC system clock option unchecked. Next choose a root password for your new system. Make it secure, and write it down. We plan to use this password for virtually everything on your new system. The install process begins. This includes MySQL, Apache, PHP, CUPS, Samba, WebMin, Subversion, SendMail, Yum, Bluetooth support, SSL, Perl, Python, the kernel development package, and much more. In about 15 minutes depending upon the speed of your PC, the install will reboot. During the reboot, be sure to eject the install CD. You must have an Internet connection now to complete the install so plug in a 10/100 cable if you haven't done so already. After reboot, the system will start up with CentOS 5.5, then you'll be prompted for the version of PBX in a Flash you wish to install. If you want the latest and greatest version of Asterisk 1.4, choose PIAF-SILVER. The installer will then download and install Asterisk and FreePBX, and search for the necessary installation script and payload file on pbxinaflash.net. If that site happens to be down, the script will go to pbxinaflash.com for the same payload file. Just to repeat, if you don't have Internet connectivity, then the installation cannot complete. When the installation finishes, reboot your system and log in as root. The IP address of your PBX in a Flash system will be displayed once you log in. If it's blank, type service network restart after assuring that you have Internet connectivity and access to a DHCP server that hands out IP addresses. Typing ifconfig should display your IP address on the eth0 port. Write it down. We'll need it in a minute.

Now that you've logged in as root, you should see the IP address displayed with the following command prompt: root@pbx:~/. If instead you see bash displayed as the command prompt and it's not green, then the installation has not completed successfully. This is probably due to network problems but also could be caused by the time being set incorrectly on your server. You can't compile Asterisk if the time on your computer is a date in the past! For this glitch you have to start over. If it's a network issue, fix it and then reboot and watch for the eth0 connection to complete. Assuming it doesn't fail the second time around, the installation will continue. Likewise, if you do not have DHCP on your network, the installation will fail because the PBX will not be given an IP address. Simply type netconfig, fill in the blanks and reboot. Tom's Guide goes into more troubleshooting detail. The install will recommence.

Four Steps to Complete the Install
There are several important things to do to complete the installation. First, log into your server as root and run the following two commands to bring your system current: update-programs then update-fixes. Next, decide how to handle the IP address for your PBX in a Flash server. The default is DHCP, but you don't want the IP address of your PBX changing. Phones and phone calls need to know how to find your PBX, and if your internal IP address changes because of DHCP, that's a problem. You have two choices. Either set your router to always hand out the same DHCP address to your PBX in a Flash server by specifying its MAC address in the reserved IP address table of your router, or run netconfig at the command prompt and assign a permanent IP address to your server. Be aware that netconfig no longer is a part of CentOS 5.5. We added it back in as part of the install. If you update your CentOS configuration, you will need to reinstall it by running update-scripts, then update-fixes, and then install-netconfig. If you experience problems with the process, see this message thread on the forum. The last configuration requirement probably accounts for more beginner problems with Asterisk systems than everything else combined. Read the next section carefully and do it now!

Getting Rid of One-Way Audio
There are some settings you'll need to add to /etc/asterisk/sip_custom.conf if you want to have reliable, two-way communications with Asterisk: nano -w /etc/asterisk/sip_custom.conf. The entries depend upon whether your Internet connection has a fixed IP address or a DHCP address issued by your provider.

If you have a fixed IP address, then enter settings like the following using your actual public IP address and your private IP subnet:

externip=180.12.12.12
localnet=192.168.1.0/255.255.255.0 (NOTE: The first 3 octets need to match your private IP addresses!)

If you have a dynamic IP address, here's a little trick from one of our PBX in a Flash readers. All we really need is a method to frequently verify your IP address so we'll run a cron job with the script below every 5 minutes. If it finds that your outside IP address has changed, it will automatically update your sip_custom.conf file with the new address. To use this approach, create a file in /var/lib/asterisk/agi-bin named ip.sh. Here's the code:

#!/bin/bash
localnet="192.168.0.0"

IPFILE='/var/log/asterisk/externip'

if [ ! -f "$IPFILE" ]; then
echo "creating $IPFILE"
echo first_time_usage > $IPFILE
fi

lastip=`cat $IPFILE`

externip=`curl -s -S --user-agent "Mozilla/4.0" http://myip.pbxinaflash.com \
| awk 'NR==2'`


if [ $externip != $lastip ]; then

echo "$externip" > $IPFILE

echo "externip=$externip" > /etc/asterisk/sip_custom.conf
echo "localnet=$localnet/255.255.255.0" >> /etc/asterisk/sip_custom.conf

echo "nat=yes" >> /etc/asterisk/sip_custom.conf

asterisk -rx "dialplan reload" ;

else

exit 0;

fi

On line 2 of the above code, enter the internal subnet for your server. This is usually 192.168.0.0 or 192.168.1.0. YMMV!

Save the file and give it execute permissions: chmod +x /var/lib/asterisk/agi-bin/ip.sh. Then make asterisk the file owner: chown asterisk:asterisk /var/lib/asterisk/agi-bin/ip.sh.

Finally, add the following entry to the bottom of /etc/crontab:

*/5 * * * * asterisk /var/lib/asterisk/agi-bin/ip.sh > /dev/null

One final gotcha is worth mentioning. If you are using a VPN setup such as the one covered in our VPN in a Flash tutorial, then be aware that your localnet settings in sip_custom.conf must include entries for all of the subnets being used on your various VPN servers. The entries might look like this:

externip=50.212.212.124
localnet=192.168.1.0/255.255.255.0
localnet=192.168.0.0/255.255.255.0

If you fail to include localnet entries for each VPN subnet, then the RTP traffic for your calls still will be routed through your standard ports and will not be in the encrypted VPN tunnel.

Getting Your System Up to Date
Tom King, one of our lead developers, has gone to great pains to make it easy for you to always have a current system. All you have to do is type a few commands, but you do have to type them. So do it now! After logging in as root, type update-programs to get the latest PBX in a Flash scripts installed on your system. This doesn't run them, it merely makes them available for you to run them. Once you complete this step, you can always review the latest scripting options by typing help-pbx. Now run update-fixes to apply the latest patches to your PBX in a Flash system. When it completes, you're up to date. If you want the latest version of Asterisk, it's easy! Just run update-source then rerun update-fixes. In the case of PBX in a Flash 1.7.5.5 SILVER and BRONZE, you'll have the latest version of Asterisk 1.4 or 1.6.2.


There is still lot more content in the article.
For More details and supporting images visit the original article on Knol
Source Knol: PBX in a Flash

Article shared under Creative Commons Attribution 3.0 License

No comments: