Home » Technology » Newbie’s Guide to Asterisk@Home 2.4: Unabridged Soup-to-Nuts Installation Guide

The Most Versatile VoIP Provider: FREE PORTING

Newbie’s Guide to Asterisk@Home 2.4: Unabridged Soup-to-Nuts Installation Guide

blankWant a rock-solid PBX at a rock-bottom price: free! Well, it's almost Ground Hog's Day so here we go again! Asterisk@Home 2.4 has hit the street because of a serious bug-fix release of Asterisk®. Now you get version 1.2.3 of Asterisk, and you also get the latest and greatest version of Linux, CentOS 4.2; the latest Festival Speech Engine (1.96); the latest version of the Asterisk Management Portal (1.10.010); the Flash Operator Panel (version 0.24); Open A2Billing; Digium card auto-configuration; NVfaxdetect support; loads of AGI scripts including weather forecasts and wakeup calls; xPL support; the SugarCRM Contact Management System with the Cisco XML Services interface and Click-to-Dial support; plus lots more. And, yes, it still fits on a single CD! Note: A new version of Asterisk (1.2.4) was released yesterday to fix a serious memory leak so you can expect yet another version of Asterisk@Home and yet another soup-to-nuts tutorial shortly. Simply stated, don't put this version into production without at least implementing the Bleeding Edge 1.2.4 upgrade at the end of this article ... but we're making progress.

Editor's Note: This version of Asterisk@Home has been superceded. For the latest tutorial on or after March 13, click here.

The installation process is pretty straightforward. You download the 2.4 ISO image from here, burn a CD (click here if you need a refresher course), use an old clunker PC or a $200 WalMart special (see inset), insert the CD you made, plug your machine into the Internet and turn it on. Then watch while Asterisk@Home loads CentOS/4.2 and all the Asterisk and Linux goodies imaginable: Apache, SendMail, Comedian Mail, SugarCRM, MySQL, PHP, phpMyAdmin, SSH, Bluetooth, the Asterisk Management Portal, the Flash Operator Panel, Call Detail Reporting, and on and on. We've covered how to use most of the Linux products in our Mac HOW-TO's (see sidebar), and they work exactly the same way with Asterisk@Home so keep reading. And, yes, this install will reformat (aka ERASE) your hard disk before it begins, but it now warns you first.


Loading CentOS/4 and Asterisk 1.2.3. Here's how the 2.4 install went for us, and we'll walk you through getting everything set up so that it can be used as a production server. Once the install begins, you can expect to eat up about 25 minutes with the CentOS 4.2 install. The install CD then will eject itself, reboot the system, and begin the Asterisk compile and installation. That takes about 25 more minutes to complete.

Securing Your Passwords. When it's finished and reboots, log in as root with password as your password. Type help-aah for a listing of the five passwords that need to be changed. Change them all NOW!

passwd
passwd admin
passwd-maint
passwd-amp
passwd-meetme

Getting the Latest CentOS Updates. Once your system is secure, load all of the application updates for CentOS 4.2. There now are over 50 updates and installs so be patient. The update command to issue is yum -y update.

Activating Bluetooth Support. Once the updates are completed, activate Bluetooth support if you plan to use it with our Follow-Me Phoning proximity detection application. Run setup, down arrow to System Services, press ENTER, down arrow to bluetooth and press the space bar, tab to OK, press ENTER, tab twice to Quit and press ENTER.

Rebuilding Zaptel. First, reboot your system: shutdown -r now. Because a new version of the kernel is installed as part of the yum update, you'll need to rebuild support for ZAP devices. Log in as root and type the following command: rebuild_zaptel. Then reboot your system: shutdown -r now. Now log in as root again and type genzaptelconf. Reboot once more and you're all set to go: shutdown -r now. You only need to rebuild Zaptel when there is a kernel update as there was with this yum update.

Simplifying SSH. If you're going to be connecting to other servers from your new Asterisk@Home 2.4 system using SSH or SCP, then build your new RSA key pair now. This lets you use SSH and SCP (secure copy) without having to enter a password each time. You can also automate backups and proximity detection scripts as we've explained previously here. Log in to your new Asterisk@Home 2.4 server as root. From the command prompt, issue the following command: ssh-keygen -t rsa. Press the enter key three times. You should see something similar to the following. The file name and location in bold below is the information we need:

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
1d:3c:14:23:d8:7b:57:d2:cd:18:70:80:0f:9b:b5:92 root@asterisk1.local

Now copy the file in bold above to your other Asterisk servers, Linux machines, and Macs. There's probably a way on PCs as well, but I've given up on that platform particularly after Sony's latest security stunt so you're on your own there. From your Asterisk@Home 2.4 server using SCP, the command should look like the following (except use the private IP address of each of your other Asterisk or Linux servers instead of 192.168.0.104). Provide the root password to your other servers (one at a time) when prompted to do so.

scp /root/.ssh/id_rsa.pub root@192.168.0.104:/root/.ssh/authorized_keys

On a Mac running Mac OS X, the command would look like this (using your username and your Mac's IP address, of course):

For user access only: scp /root/.ssh/id_rsa.pub wardmundy@192.168.0.104:/Users/wardmundy/.ssh/authorized_keys
For full root access: scp /root/.ssh/id_rsa.pub root@192.168.0.104:/var/root/.ssh/authorized_keys

Once the file has been copied to each server, try to log in to your other server from your Asterisk@Home 2.4 server with the following command using the correct destination IP address, of course:

ssh root@192.168.0.104

You should be admitted without entering a password. If not, repeat the drill or read the complete article and find where you made a mistake. Now log out of the other server by typing exit.


Installing WebMin. We don't build Linux systems without installing WebMin, the Swiss Army knife of the Linux World. You can use it to start and stop services, check logs, adjust startup scripts, manage cron jobs, babysit your SendMail server, and many, many other tasks that are downright painful without it. If you ever need help from others, WebMin is a great tool for letting others help you.

There are lots of ways to install WebMin. We prefer the easy way which is to issue the following commands at a Linux prompt after logging in as root. Note: WebMin updates come out all the time. If you want to be sure you start with the latest and greatest version, go to their web site first and write down the number of the current version. Then substitute it below when issuing these commands. Note that there is a new version of WebMin since our previous article on Asterisk@Home 2.2 was published.

cd /root
mkdir webmin
cd webmin
wget http://internap.dl.sourceforge.net/sourceforge/webadmin/webmin-1.260-1.noarch.rpm
rpm -Uvh webmin*


WebMin runs its own web server on port 10000. To start WebMin, issue this command: /etc/webmin/start. You access it with a web browser pointed to the IP address of your Asterisk box at that port address, e.g. http://192.168.0.108:10000. The login name is root. Then type in your root password and press enter. The main WebMin screen will display. We really don't want the WebMin server starting up each time the OS reboots so do the following. Once you're logged in to WebMin, choose System->Bootup and Shutdown and then click on webmin. Click the No button beside Start at boot time, and then click the Save button. Before we forget, we need to also make one change to the new Asterisk@Home configuration to avoid problems down the road. The default RTP listening ports for Asterisk@Home are set to 10000 to 20000 so there's a conflict on port 10000 with WebMin. Log in as root and, using an editor, call up the rtp.conf file: nano /etc/asterisk/rtp.conf. Now change the rtpstart port from 10000 to 10001 and save the change: Ctrl-W, Y, and press Enter. Then restart Asterisk: amportal restart. Finally, to stop WebMin when you're finished using it, issue this command: /etc/webmin/stop. You can start it any time you need it, and then use a web browser to access it. But there's no need to consume processing resources running a second web server when you're not using it.

IP Configuration for Asterisk. We need a consistent IP address or domain name both on your internal network and externally if you expect to receive incoming calls reliably. There are three pieces to the IP configuration: (1) setting the internal IP address of your Asterisk server, (2) configuring an external qualified domain name which will always point to your router/firewall, and (3) configuring your router to transfer incoming Asterisk packets to your Asterisk server. Log into your server as root using your new password. Now type ifconfig eth0 (that's "e-t-h-zero") then enter, and write down both your inet addr and your HWaddr on the Ethernet 0 interface, eth0. Inet addr is the internal IP address of your Asterisk box assigned by your DHCP server (i.e. your router/firewall). HWAddr is the MAC address of your Asterisk server's eth0 network card. To assure a consistent internal IP address, you can either configure your router/DHCP server to make certain that it always hands out this same address to your Asterisk machine, or you can manually configure an IP address for this machine which is not in the range of addresses used by your DHCP server. Almost all routers now make it easy to preassign DHCP addresses so we prefer option 1. It's generally under the tab for LAN IP Setup and is generally called something like Reserved IP table. Just add an entry and call it Asterisk PBX and specify the IP address and MAC address that you wrote down above. Now each time you reboot your Asterisk server, your router will assign it this same IP addreess. To assure a consistent external address is a little trickier. Unless you have a static (fixed) IP address, you'll want to use a Dynamic DNS service such as dyndns.org and configure your router to always advertise its external IP address to dyndns.org. DynDNS.org will take care of revising the IP address associated with your domain name when your ISP changes your dynamic IP address. Then you can configure your VoIP provider account using your fully-qualified dyndns.org domain name, e.g. windswept.dyndns.org provides access to our beach house network even though Time Warner cable hands out dynamic IP addresses which change from time to time. Finally, you'll need to log into your router and redirect certain incoming packets to the internal IP address of your Asterisk machine. If you want external access to the Apache web server on your Asterisk machine, then map TCP port 80 to the internal IP address of your Asterisk system. For WebMin external access, map TCP port 10000 to your Asterisk system. If you want remote access to your Asterisk system via SSH, then map TCP port 22 to the internal IP address of your Asterisk system. If you want external IP phones or other Asterisk servers to be able to communicate with your Asterisk system, then map the following UDP port ranges to the internal IP address of your Asterisk system:

SIP 5004-5082
RTP 10001-20000
IAX 4569

For more details, read our article on the subject.

Basic System Configuration. To get a basic Asterisk system up and running, you only need to do a few things. First, you need an Outbound Trunk to actually deliver your outbound calls to Plain Old Telephones (POTS). Second, you need to configure an Outbound Route to tell Asterisk which trunk to use to deliver your outbound calls to the intended recipients. Third, you need to configure at least one extension so that you can plug in some sort of telephone instrument to place and receive calls using your new Asterisk server. The phone can be a hardware device such as an IP telephone or a POTS phone, or it can be a software device such as a free IP softphone. The advantage of IP telephones and softphones is that they require no additional hardware besides your Asterisk server. A POTS phone or our favorite, a 5.8GHz wireless phone system with up to 10 extensions, both require an additional piece of hardware although some of the newer IP wireless phones give you the best of all worlds (see inset). To use a POTS phone, the hardware required is either a circuit board with an FXS port or an external black box (ATA device) such as a Sipura SPA-1001. If you also want to connect your Ma Bell phone line to your Asterisk server, then you need a circuit board with an FXO port or an external black box (ATA device) such as a Sipura SPA-3000. Our favorite is the SPA-3000 because it has both FXO and FXS ports in a box the size of a pack of cigarettes for under $100.


Setting Up An Outbound Trunk. You configure an outbound trunk using your web browser and the Asterisk Management Portal (AMP). But first, you have to have an account with a service provider. This is the company that carries your calls from your Asterisk server to plain old phones in your neighbor's house or Aunt Betty's in California. With VoIP, it's a good idea to have two providers, but today let's start with one. We'll save you some time and lots of money. Unless you make substantial international calls regularly, use TelaSIP/VoipExpress. If you want to know why, read the full article here. Or just try a free call for yourself using our server. Basically, $5.95 a month gets you a local number in your choice of area code with free incoming calls, and 2¢ per minute for outbound calls to anywhere in the U.S. $9.95 a month buys you all of that plus free outbound calls in the area code of the phone number you select. $14.95 a month gets you a number in the area code of your choice with unlimited incoming calls and unlimited outbound calls to anywhere in the U.S. There are no sneaky add-on fees and no obnoxious terms of service. Just be sure to tell them to configure your account for use with Asterisk. They also have very reasonable business plans. If, on the other hand, you'd prefer to try another provider, take a look at our easy setup guides for most of the major VoIP providers here.

Once you have your account name and password, point your web browser to the IP address of your new Asterisk@Home 2.4 server and log in as maint with the password you selected. Then choose AMP->Setup->Trunks->Add SIP Trunk assuming you're using TelaSIP. NOTE to existing users: if you already have an Asterisk server using your TelaSIP account, don't use the same account at the same time on your new Asterisk@Home 2.4 server! Plug in the CallerID number you were assigned for your account. Set Maximum Channels to 2. For the Dial Rules, use the following (substituting your local area code for 404 below):

1|NXXNXXXXXX
NXXNXXXXXX
404+NXXXXXX

In the Outgoing Settings section, name your trunk telasip-gw. Then enter the following for the Peer Details using your own account name for username and fromuser and using your own assigned password for secret:

context=telasip-in
dtmfmode=rfc2833
fromuser=youraccountname
host=gw3.telasip.com
insecure=very
secret=yourpassword
type=peer
username=youraccountname

Leave the Incoming Settings section blank, and in the Registration String, enter the following using your account name and password:

youraccountname:yourpassword@gw3.telasip.com

Click the Submit Changes button, and then click the red bar to reload Asterisk. Now we need to add the context which will actually process the incoming calls from TelaSIP. Choose AMP->Maintenance->Config Edit->extensions_custom.conf and add the following code at the bottom of the file substituting your new phone number for 4041234567. Save the file and reload Asterisk to finish the setup. See the Comments to this post for a more versatile approach which will let you use your TelaSIP line for Ring Groups.

[telasip-in]
exten => 4041234567,1,NoOp(Incoming call on TelaSIP #4041234567)
exten => 4041234567,2,Dial(local/200@from-internal,20,m)
exten => 4041234567,3,VoiceMail(200@default)
exten => 4041234567,4,Hangup

Configuring an Outbound Route. Now we need to tell Asterisk where to send our outbound calls when we dial them. To get started, we'll just send everything to the TelaSIP trunk we just configured. Choose AMP->Setup->Outbound Routing->Add Route. For Route Name, use Outside. Leave the password blank. For Dial Patterns, enter the following:

NXXXXXX
NXXNXXXXXX
1NXXNXXXXXX

For the Trunk Sequence, choose SIP->telasip-gw from the drop-down list. Then click Submit Changes. Be sure you also delete the sample outbound route that came with the install, or your outbound calls may go nowhere. Finally, click the red bar to save your new Outbound Routing setup.


Configuring an Extension. You have to have an extension to make and receive calls with Asterisk@Home so let's build one. Choose AMP->Setup->Extensions->SIP to begin. For the Extension Number, let's use 200 to keep things simple. For the Display Name, make up something that tells where this phone will be located, e.g. Kitchen. For the Outbound CID, use 200. For secret, make up a password for this extension. For Voicemail and Directory, choose Enabled. Plug in your password again. Type in your email address, and, if you want to also be paged when you get a new voicemail, type in a pager email address. Click the Yes button beside Email Attachment, and leave the other settings alone. Now click the Submit button and then click the red bar to save your changes and reload Asterisk.


Downloading a Free Softphone to Test Asterisk. Unless you already have an IP phone, the easiest way to get started and make sure everything is working is to install an IP softphone. You can download a softphone for Windows, Mac, or Linux from CounterPath. Or download the pulver.Communicator. Both are free! Just install and then configure with the IP address of your Asterisk@Home 2.4 server. For username and password, use your extension number and password from above. Once you make a few test calls, don't waste any more time. Buy a decent SIP telephone. We think the best value in the marketplace with excellent build quality and feature set is the under $100 GrandStream GXP-2000. It has support for four lines, speaks CallerID numbers, has a lighted display, and can be configured for autoanswer with a great speakerphone. Short of paying three times as much, that's as good as desktop phones get. If you want to use Asterisk throughout your home, buy a good 5.8GHz wireless phone system with plenty of extensions (our two favorites are shown in the insets below) and then purchase an SPA-3000 to connect up both your home phone line and all your cordless phones. Our tutorial will show you how. The final option is to use a wireless IP phone which is the best of both worlds, a cordless phone that talks IP telephony without an ATA blackbox such as the Uniden UIP1868 (see also insets above).


Activating Email Delivery of VoiceMail Messages. When you're out and someone leaves you a voicemail message, Asterisk@Home will let you forward that voicemail message to your email address as a .wav file which can be played within most email client software. Or you can have Asterisk@Home send an instant message to your cell phone or pager telling you who called, what their phone number was, and how long a voicemail message the person left for you. Or you can do both. In addition, you can tell Asterisk@Home whether to delete the voicemail from your Asterisk server after sending it to your email account. In short, you now can manage all of your incoming email and voicemail from a single place, your email client. In order to send out emails from your Asterisk@Home server, you'll need to make a few changes. First, make this adjustment to the /etc/hosts file on the server. Since anonymous emails are blocked by most ISPs, you'll need a fully-qualified domain name for your server. If you don't have your own domain, the easiest alternative is to use the fully-qualified domain name that your ISP assigns to the IP address for your broadband connection. Don't forget to update it when your ISP changes your IP address! To find out what your fully-qualified domain name is, go to a command prompt on your Asterisk server and type: nslookup 123.456.789.001 substituting your public IP address for the preceding numbers. Then write down the name entry without the trailing period. Now edit the hosts file: nano /etc/hosts. Move the cursor to the second line which reads 127.0.0.1 asterisk1.local , and then move the cursor over the first letter of the first domain name shown, usually asterisk1.local. Now type in the fully-qualified domain name you previously wrote down and add a space after your entry. Don't erase the existing entry! Save your settings: Ctrl-X, y, enter. Now restart network services on your Asterisk machine: service network restart. Next, you need to modify the email message which delivers your voicemails so that it includes your fully-qualified domain name. Don't do this in AMP, or you'll mess up the formatting of the email message. You can download a fresh copy here if you need it. Instead, use nano: nano -w /etc/asterisk/vm_email.inc. Press Ctrl-W, type /cgi, and press the enter key. You're now positioned where you need to type either the fully-qualified domain name for your Asterisk server or the private IP address if you only want to read your emails from behind your firewall. When you start typing, the text display is going to jump all over the place because of word wrap. Don't freak out. You haven't messed anything up. Once you complete your entry, don't erase or change anything else. Save the file: Ctrl-X,Y, then enter. Now go into AMP->Maintenance->Config Edit->vm_general.inc with a web browser. Change the serveremail entry to an email name at the fully qualified domain you used in your /etc/hosts file above. Then save your configuration and restart Asterisk. If you continue with this setup and still don't receive emails, here's another configuration change that is sometimes necessary. On the Asterisk terminal, log in as root. Switch to the directory where the SendMail configuration file is stored: cd /etc/mail. Make a backup of the config file: cp sendmail.cf sendmail.cf.bak. Then issue the following command: echo CGasterisk.dyndns.org >> sendmail.cf. Substitute the actual domain name of your Asterisk server for asterisk.dyndns.org, but be sure it's preceded by CG with no intervening spaces.Then reboot your server and try again: shutdown -r now. Finally, if your ISP doesn't permit downstream mail servers (that's you), then take a look at this link which will show you how to designate your ISP as your SMTP smart host using SendMail.


To configure the voice mail forwarding options, go into the Setup tab of the Asterisk Management Portal using a web browser. Click on Extensions and then click on an extension you already have configured. In the Voicemail and Directory section of the form, enter either (or both) your email address and your pager or cellphone's text messaging address. To email the voicemails as attachments, just click Yes beside Email Attachment. To delete the voicemail message from your voicemail inbox after sending it to your email address (not recommended until you first get it working correctly), click Yes beside Delete Vmail. For those using a dynamic IP address with phones at remote locations connecting to your Asterisk server, we'll show you how to automate the process of changing your Asterisk server's IP address in a future column.

Call Recording Fixed. This update fixes inbound and outbound call recording which now works reliably. You can set your preferences for call recording when you set up each extension. The recordings are stored in /var/spool/asterisk/monitor unless you set other preferences in agents.conf.

Paging Fixed. If you want to use paging with your Asterisk system, the sound card problems in Asterisk@Home 2.1 and Asterisk 1.2 have been resolved. Review this posting on SourceForge for additional details. It now works with full and half-duplex sound cards. Thanks, Tracy!

Wakeup Calls Good News & Bad News. The good news is that Asterisk@Home 2.4 includes a new version of the Wakeup Call program, and the default setup works. The bad news is that the "annoy" option which is supposed to force the user to key in a number to prove they're awake still doesn't work. And, the wakeup call application now uses a different method of scheduling wakeup calls which broke our TeleYapper and Telephone Reminder applications. Mental note for would-be developers, don't rely on someone else's code to keep your code working reliably. This is especially true in the open source marketplace. Everyone is full of new ideas, and they don't necessarily stop to think of the impact the improvements will have on other folks' applications. We'll have new versions of our applications ... soon. Bear with us while we hold off for Asterisk@Home 2.5 just so we don't have to repeat the drill again.

Adjusting Call Parking Extensions. Traditionally, pressing the pound key (#) and dialing extension 700 parked a call on Asterisk@Home systems and notified you of the parked extension. The call then could be picked up by dialing the parked extension in the range of 701 to 799 from any extension on your system. The new setup is to press # and dial 70 to park a call and 71-79 to pick it up. If you prefer the old setup, you'll need adjust the settings in features.conf. Go to AMP->Maintenance->Config Edit->features.conf and make it look like this:

[general]
parkext => 700 ; What ext. to dial to park
parkpos => 701-799 ; What extensions to park calls on
context => parkedcalls ; Which context parked calls are in

Directory Lookup Fixed. Pressing the pound key (#) from any phone connected to your Asterisk server now calls up a directory lookup function using the Asterisk Management Portal (AMP).

Max Channels Bug Remains. A bug has been reported because of a deprecated command that makes Asterisk@Home's calculation of maximum channels invalid. To fix it, goto AMP->Maintenance->Config Edit->extensions.conf->macro-dialout-trunk and comment out line s,7 so that it looks like this:

;exten => s,7,CheckGroup(${OUTMAXCHANS_${ARG1}})

Then insert a new line s,7 just below it which looks like this:

exten => s,7,GotoIf($[ ${GROUP_COUNT()} > ${OUTMAXCHANS_${ARG1}} ]?108)

Then click the Update button and reload Asterisk to activate the change.

Syntax Error in extensions.conf Causes Failed Incoming Calls. One of our readers has discovered a nasty little bug in extensions.conf that will cause some incoming calls to fail. Edit extensions.conf->macro-dial and change line s,22 as follows. Then reload Asterisk.
Before:

exten => s,22,GotoIf($[$[${HuntMembers} >= 1]?30 )

After:

exten => s,22,GotoIf($[$[${HuntMembers}] >= 1]?30 )

Tweaking SIP.conf. There are a few changes we recommend you make in the [general] context of the sip.conf file. Using the Asterisk Management Portal, go to AMP->Maintenance->Config Edit->sip.conf. It's a good idea to include your actual CallerID number of your default outbound trunk here instead of Default. We also recommend that you add allow=gsm just below the existing allow=alaw line in the file. You may also want to include progressinband=yes which assures that callers will hear ring tones when placing calls even if your provider doesn't provide them. This is a fairly common complaint with BroadVoice in particular. Don't forget to reload Asterisk once you make these changes: AMP->Setup->Incoming Calls->Submit Changes and then click the Red bar.

Connecting Remote Extensions or a Remote Asterisk Server. If you plan to connect remote extensions to your Asterisk server, then add the following entries to sip.conf above using your own fully-qualified domain name and the first three octets of the private IP address of your Asterisk server:

externip = myasteriskbox.dyndns.org
localnet=192.168.0.0/255.255.255.0
nat=yes

You'll also either need to define your Asterisk server as a DMZ device in your firewall setup, or you can open the following UDP ports and map all of them to the private IP address of your Asterisk box: 4569, 5004-5082, and 10000-20000. If you only hear half of a conversation with a remote extension, it's usually a NAT problem meaning you probably forgot to do the port mapping drill. We plan to cover remote extensions and interconnecting Asterisk servers in more detail in a future column so stay tuned. In the meantime, if you have a dynamic DNS connection that changes your IP address regularly and you don't want to wrestle with manually updating your Asterisk server each time there's a change, just download chandave's sip reload script and copy it to your /etc/asterisk directory. Then execute the following commands while logged in as root:

chown asterisk:asterisk /etc/asterisk/sip_reload.sh
export EDITOR=nano
crontab -e
00,05,10,15,20,25,30,35,40,45,50,55 * * * * root /bin/sh /etc/asterisk/sip_reload.sh >/dev/null 2>&1

Save your crontab addition in the usual nano way, and you're all set: Ctrl-X, y, then enter. This clever little script will make sure your Asterisk server always knows its own IP address regardless of how often your ISP changes it. And you'll never lose inbound connectivity from remote extensions or servers for over 5 minutes. If you'd like to read the full discussion, visit this link on the Voxilla forum.

Managing Incoming Calls. For long time readers of this column, you already know that our recommended strategy for handling incoming calls is to set up a simple Stealth AutoAttendant. Basically, this is a welcome message that greets your callers and then transfers them to an extension or ring group of your choice. The advantage of this approach is that it also lets callers like you press buttons to navigate through various options on your Asterisk system without advertising them to the public at large. If you're just getting started with Asterisk, you can read all about setting up a Stealth AutoAttendant here. If you'd prefer to manage your incoming calls with AMP, you'll still need to fix the [from-sip-external] context in the extensions.conf file, or all your incoming SIP and IAX calls will ring busy. To fix it, choose AMP->Maintenance->Config Edit->extensions.conf->from-sip-external. Comment out all the lines in the existing file by adding a semicolon at the beginning of each line. Then add the following line, save your changes, and reload Asterisk.

exten => _.,1,Goto(from-pstn-timecheck,s,1)


New Custom Speed Dialing. Asterisk@Home 2.4 has a built-in speed dialing utility. The reserved speed dial numbers are 300 to 399. Adding a number to your speed dial list is easy. Just pick up an extension and dial 300-3xx-6781234567 where 3xx is the speed dial code you want to create and 6781234567 is the phone number you want dialed when you enter the speed dial code. Just make sure you enter the number to be called in a format that is supported by your Asterisk dialplan, i.e. if outside calls need to be preceded by a 1 or a 9, then the number should be entered in a matching format. You can look up speed dial numbers by dialing an asterisk followed by the 3-digit speed dial code, e.g. *301 would tell you the number stored in speed dial 301. If you need additional flexibility with both web browser and phone access as well as 1 to 5-digit speed dial codes, download our free AsteriDex robodialer.

Fixed A2Billing: Asterisk Calling Card Platform. This web-based application allows you to generate and issue calling cards to individuals so that they can place calls remotely through your Asterisk server. If you've always wanted to be just like AT&T, here's your Big Chance! There's very little that you can do with an AT&T calling card that can't be done as well or better by you using A2Billing. And, it won't take an M.B.A. to undercut AT&T's calling card rates and still make buckets of money. All you need now are a few customers. Heck, I'll sign up with you. I sign up for everything. But first, a word of caution. Assuming your Asterisk server has web exposure on the Internet, you need to secure the admin and root passwords in this application whether you use it or not. To access the application, go to http://192.168.0.104/a2billing/ using the actual internal IP address of your Asterisk server. Log in as root with a password of myroot. Click on the ADMINISTRATOR tab in the left column and then click Show Administrator. Now click on the Edit button beside each of the two administrator accounts and change the passwords to something secure. If you really would like to learn more about it, documentation for the application is available here. And, if you decide to use the application, you'll need to uncomment the 6 actual dialplan lines in extensions_custom.conf and reload Asterisk:

;[custom-callingcard]
;exten => s,1,Answer
;exten => s,2,Wait,2
;exten => s,3,DeadAGI,a2billing.php
;exten => s,4,Wait,2
;exten => s,5,Hangup

Footnote: The missing A2Billing code from Asterisk@Home 2.1 has been added. You can read all about the problem here. There's also a pretty good step-by-step setup guide for Asterisk@Home here.

SugarCRM Contact Management. Asterisk@Home includes the latest and greatest version of the best open source contact management application on the planet, SugarCRM. You access the application with a web browser: http://192.168.0.104/crm/ substituting the private IP address of your Asterisk box, of course. Specify admin for your username and password for your password. Whether you use the application or not, change the admin password. It's easy. Just click the Administrator link under Welcome admin. Then click the Change Password button. Complete documentation for the application is available here. If contact management is your thing, knock yourself out, and we'll talk to you next spring when you finish getting everything set up to run your business. It's a great product, but be prepared to invest lots of time in the project if you expect to use it productively.

Incoming Fax Support. The NVfaxdetect software that we showcased back in December, 2005, now is included in Asterisk@Home 2.4. The major advantage of NVfaxdetect is that it works with SIP and IAX trunks as well as ZAP lines. Unfortunately, you'll still need to manually configure the Asterisk Management Portal to use it. Thanks to Thunderbird in Australia, it's pretty easy to make the necessary changes. First, enable faxing support. Go to AMP->Setup->General Settings and set Extension of Fax Machine to system. Then fill in your email address. Click the Submit Changes button to save your changes. This sets the default route for incoming faxes. If you want to specify different fax destinations for different DID trunks, then set up Inbound Routing using AMP and define the fax extension as system (instead of default) with an email address for delivery of the fax for each particular DID. You'll also need to make sure you have outbound email functioning on your Asterisk server (see above), or none of the rest of this matters. NVfaxdetect converts your incoming faxes to PDF documents and then emails them to you. So the next step is to get that conversion functionality working. Log in to your Asterisk server as root and type the following command: install-pdf. Now make a backup copy of your extensions.conf file: cp /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bak. We're going to do some heavy editing of the extensions.conf file so be careful with your cutting-and-pasting: nano -w /etc/extensions.conf. When you're finished, save your changes and restart Asterisk: amportal restart.

Find and delete the entire [from-pstn-reghours] context. Replace it with the following:

[from-pstn-reghours]
exten => s,1,GotoIf($[${FAX_RX} = disabled]?from-pstn-reghours-nofax,s,1:2) ; if fax detection is disabled, then jump to from-pstn-nofax - else continue
exten => s,2,Answer
exten => s,3,Playtones(ring) ; play fake ring so caller doesn't wonder what's going on
exten => s,4,NVFaxDetect(4) ; detect faxes while playing ring sound - goes to "fax" extension if detected
exten => s,5,SetVar(intype=${INCOMING})
exten => s,6,Cut(intype=intype,-,1)
exten => s,7,GotoIf($[${intype} = EXT]?8:9) ; If INCOMING starts with EXT, then assume its an extension
exten => s,8,Goto(ext-local,${INCOMING:4},1)
exten => s,9,GotoIf($[${intype} = GRP]?10:11) ; If INCOMING starts with GRP, then assume its a ring group
exten => s,10,Goto(ext-group,${INCOMING:4},1)
exten => s,11,GotoIf($[${intype} = QUE]?12:13)
exten => s,12,Goto(ext-queues,${INCOMING:4},1)
exten => s,13,Goto(${INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => h,1,Hangup

Find and delete the entire [from-pstn-afthours] context. Replace it with the following:

[from-pstn-afthours]
exten => s,1,GotoIf($[${FAX_RX} = disabled]?from-pstn-afthours-nofax,s,1:2) ; if fax detection is disabled, then jump to from-pstn-nofax - else continue
exten => s,2,Answer
exten => s,3,Playtones(ring) ; play fake ring so caller doesn't wonder what's going on
exten => s,4,NVFaxDetect(4) ; detect faxes while playing ring sound - goes to "fax" extension if detected
exten => s,5,SetVar(intype=${AFTER_INCOMING})
exten => s,6,Cut(intype=intype,-,1)
exten => s,7,GotoIf($[${intype} = EXT]?8:9) ; If INCOMING starts with EXT, then assume its an extension
exten => s,8,Goto(ext-local,${AFTER_INCOMING:4},1)
exten => s,9,GotoIf($[${intype} = GRP]?10:11) ; If INCOMING starts with GRP, then assume its a ring group
exten => s,10,Goto(ext-group,${AFTER_INCOMING:4},1)
exten => s,11,GotoIf($[${intype} = QUE]?12:13)
exten => s,12,Goto(ext-queues,${AFTER_INCOMING:4},1)
exten => s,13,Goto(${AFTER_INCOMING},s,1) ; not EXT or GR1 - it's an auto attendant
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => h,1,Hangup

Find and delete the entire [ext-fax] context. Replace it with the following:

[ext-fax]
exten => s,1,Answer
exten => s,2,Goto(in_fax,1)
exten => in_fax,1,StopPlaytones ; you must do this or it will play ring sounds over your fax
exten => in_fax,2,GotoIf($[${FAX_RX} = system]?3:analog_fax,1)
exten => in_fax,3,Macro(faxreceive)
exten => in_fax,4,Hangup
exten => analog_fax,1,GotoIf($[${FAX_RX} = disabled]?3:2) ;if fax is disabled, just hang up
exten => analog_fax,2,DBGet(DIAL=DEVICE/${FAX_RX}/dial);
exten => analog_fax,3,Dial(${DIAL},20,d)
exten => analog_fax,4,Hangup
exten => out_fax,1,txfax(${TXFAX_NAME}|caller)
exten => out_fax,2,Hangup
exten => h,1,system(tiff2ps -2eaz ${FAXFILE} | ps2pdf - ${FAXFILE}.pdf)
exten => h,2,system(mime-construct --to ${EMAILADDR} --subject "Fax from ${CALLERIDNUM} ${CALLERIDNAME}" --attachment ${CALLERIDNUM}.pdf --type application/pdf --file ${FAXFILE}.pdf)
exten => h,3,system(rm ${FAXFILE} ${FAXFILE}.pdf)
exten => h,4,Hangup()

Be aware that NVfaxdetect can be a bit quirky. You may need to fine tune the timing mechanism in the actual NVfaxdetect(4) lines above. If 4 is too long or too short a delay to detect a fax call, try 10 or nothing at all. 10 works for us. 4 works in Australia apparently. If you need more details, read our original article on this topic. It also explains how to get all of this working with the Nerd Vittles Stealth AutoAttendant if you're using it.

Asterisk Recording Interface. A new web-based utility for managing your voicemail now is included in AMP and can be accessed by clicking Voicemail & Recordings on the initial AMP screen at the IP address of your Asterisk system. It also can be accessed at http://Asterisk-IP-address/recordings/. To log in to the Asterisk Recording Interface (ARI), just enter an extension number on your Asterisk system and the password for that extension. From the web interface, you can manage your voicemail messages including playing them back, you can review the call log to this extension, and you can set your voicemail password as well as your desired setup for recording calls by setting the call monitor defaults for this extension. Very cool!

Other Out-of-the-Box Utilities. Asterisk@Home 2.4 comes bundled with a number of additional utilities. Here are some of them. You can retrieve the current time by dialing *60. If the time is wrong, you can reset your default time zone by logging into your server as root and typing config. A current weather report for New York is available by dialing *61. You can change the city by following our previous tutorial which is available here. Something has come unglued in the festival script, however, because there is a noticable 10-second delay between each line of text that is read now. To set up a wakeup call from any extension, dial *62. To determine the phone number of any extension, just dial *65. You can use the default MeetMe conferencing system from any or all of your extensions by dialing 8 plus the number of an existing extension. Additional conference rooms can be added by editing meetme_additional.conf. Finally, you can record customized voice prompts for your system by dialing 5678 from any extension. Before this will work, edit the extensions_custom.conf file (AMP->Maintenance->Config Edit->extensions_custom.conf) and uncomment the seven lines shown below which are located at the bottom of the file. Just remove the leading semicolons. You'll also need to uncomment the following line near the top of file at the beginning of the [from-internal-custom] context: ;include => custom-recordme.

;[custom-recordme]
;exten => 5678,1,Wait(2)
;exten => 5678,2,Record(/tmp/asterisk-recording:gsm)
;exten => 5678,3,Wait(2)
;exten => 5678,4,Playback(/tmp/asterisk-recording)
;exten => 5678,5,Wait(2)
;exten => 5678,6,Hangup

Once you make a recording, it needs to be moved to /var/lib/asterisk/sounds/custom with a new filename.gsm, e.g. mv /tmp/asterisk-recording.gsm /var/lib/asterisk/sounds/custom/hihoney.gsm. Then change the ownership of the file: chown asterisk:asterisk /var/lib/asterisk/sounds/custom/hihoney.gsm. You then can play the recording with a line like this in your dialplan: exten=>s,1,Playback(custom/hihoney) where hihoney is the name you assigned to the recording without its .gsm extension.

Where To Go From Here. After you get a functioning Asterisk system, you're ready to move on to some really cool things that make Asterisk a one-of-a-kind PBX. There are customized weather reports, web and phone-based dialers from a MySQL address book, incoming fax to PDF conversion with email delivery, blacklisting of telemarketers, bluetooth proximity detection so that your home or office calls automatically transfer to your cellphone when you depart with your bluetooth device, and on and on. You'll also want to take a more in-depth look at many of the topics we've covered above. For a complete catalog of all of our Asterisk projects and everything else we've written about Asterisk@Home, go here. Then take a look at a terrific writeup from the other side of the globe: Asterisk@Home for Dumb-Me. Finally, there's an Asterisk@Home Handbook Wiki project under development that's worth a careful look.

The Bleeding Edge. For the pioneers that just can't wait for Asterisk@Home 2.5, here's a quick and dirty way to load the new, new Asterisk 1.2.4 today. Log in to your new Asterisk@Home 2.4 server as root. Then issue the following commands in order. Be aware that this probably will break a few things including inbound fax support. But you can follow our original fax tutorial to get that working again. Everything else seems to work just fine at least in our Zap-free test machine. Enjoy!

amportal stop

cd /usr/src
wget http://ftp.digium.com/pub/zaptel/zaptel-1.2.3.tar.gz
wget http://ftp.digium.com/pub/libpri/libpri-1.2.2.tar.gz
wget http://ftp.digium.com/pub/asterisk/asterisk-1.2.4.tar.gz
wget http://ftp.digium.com/pub/asterisk/asterisk-addons-1.2.1.tar.gz
wget http://ftp.digium.com/pub/asterisk/asterisk-sounds-1.2.1.tar.gz

tar -zxvf zaptel-1.2.3.tar.gz
tar -zxvf libpri-1.2.2.tar.gz
tar -zxvf asterisk-1.2.4.tar.gz
tar -zxvf asterisk-addons-1.2.1.tar.gz
tar -zxvf asterisk-sounds-1.2.1.tar.gz

cd zaptel-1.2.3
make clean
make install
cd ..

cd libpri-1.2.2
make clean
make install
cd ..

cd asterisk-1.2.4
make clean
make install
cd ..

cd asterisk-addons-1.2.1
make clean
make install
cd ..

cd asterisk-sounds-1.2.1
make clean
make install
cd /root

amportal start

blank


17 Comments

  1. I installed fresh from the ISO, and MWI is not working. Did you notice that with your setup. Also. I had to manually create the /var/spool/asterisk/voicemail directory to be able to save a VM. Otherwise when it went to voice mail it would not allow a caller to leave you a voicemail.

    [WM: Ours works fine. Did you configure voicemail in AMP for the extension you created? This automatically sets up the necessary directories to support voicemail.]

  2. Ward – again, excellent articles! Keep ’em coming. One "tid bit" Ive picked up in chatting with Gene at TelaSIP is the ability to change the outbound CID strings. Here is the scenario – Once you start working wiht Asterisk, I suspect that many folk will take advantage of Stanaphone, IPKall, and other "free" inbound SIP services (also may have a POTS line attached through an X100P card for fail safe 911 dialing).

    Using a multi line SIP phone (I?¢ÀÜ?°?Ǭ¢?¢‚Ǩ?°?ɂİ?Ǭ®?¢‚Ǩ?°?É‚Äò?Ǭ¢ve got a few Grandstream GXP2000’s) one can create multiple accounts and dial the appropriate account – while setting the CID to appear that its from a freebie SIP line. Gene said its actually VERY simple for him – he clears the CID and YOU have to set it… simply put "sendrpid=yes" into your SIP configuration and BE SURE to set the CID for the appropriate trunk &/or extension (I use the extension to override the trunk CID for spoofing SIP numbers). Its a neat trick and still lets you use ONE great service (TelaSIP) and still have many inbound trunks.

    [WM: Neat trick! Can’t wait to try it.]

  3. Ward – aheads up about 2.4, I haven’t been able to get Teleyapper to work – it was perfect in 2.2.

    [WM: Yep. Both TeleYapper and the Telephone Reminder System are broken in 2.4. They both are going to need some retrofitting… hopefully next week.]

  4. Ward, with out you I would be no where with Asterisk. Thanks for your diligence.

    FYI it has been my experience that Call Recording files are saved here /var/spool/asterisk/monitor by default not /var/lib/asterisk/monitor.

    I would love to see a good tutorial on meetme in the future. Thanks…

    [WM: You’re right on the storage location of Call Recording files. Seems like I spend half my life in /var/lib/asterisk, and I just type it like a robot every time anything starts with var.]

  5. Hey Ward.. thanks for being so great at keeping me in the know about asterisk. What can be done about those of us who dont want to kill off our existing config files and yet still upgrade?

    [WM: Great question. Same old answer, I’m afraid. Call up each page in AMP and print the screen either to PDF or to a printer. And then start retyping. Good luck.]

  6. So I’m trying to get switched over to Asterisk@home using 2 quad span Digium cards for our old Proprietary PBX, and when the behavior switched from the ringall after hours behavior to the hunt group this morning (just put in in kind of hybrid style for testing last night) and noticed that we were not recieving any calls on the KSU (FXS’s were being used so that the asterisk box had control, but the KSU users didn’t notice too much). I loooked in the log file and noticed a syntax error durring the incomming calls that didn’t ever ring. It said there was a missing "]" and so I set off tracing the dial plan. I’ll be testing it tonight, but the default install of AAH 2.4 has a syntax error in extensions.conf under the macro "macro-dial" on line s,22
    it needs to look like this, exten => s,22,GotoIf($[${HuntMembers} >= 1]?30 , I think.

    [WM: You’re right. There is a problem. There’s one too many $[‘s after the GotoIf(. Here’s what I think needs to happen, and I’ll update the tutorial as well.]
    Before:

    exten => s,22,GotoIf($[$[${HuntMembers} >= 1]?30 )

    After:

    exten => s,22,GotoIf($[${HuntMembers} >= 1]?30 )

  7. Comments:

    Bluetooth support:

    Does this mean I can use a bluetooth phone as a ZAP trunk? Much neater, and cheaper than getting a ‘Dock-N-Talk’ http://cgi.ebay.com/Dock-N-Talk-Bluetooth-Dial-Tone-From-Cellular_W0QQitemZ6472881835QQcategoryZ3311QQssPageNameZWD1VQQrdZ1QQcmdZViewItem

    hopefully not a resource hog…

    [WM: As for Bluetooth as a ZAP trunk, take a look at this article.]

    GOT to get more memory!

    You do not have a section on getting your Networking set up. perhaps at least some discussion in the webmin, or is it assumed if you got this far you can do that?

    [WM: Good suggestion. I’ve added it although we’ve covered it in some of our previous articles. But it’s good to get everything in one place so THANKS.]

  8. I just completed "The Bleeding Edge" on a Compaq DL380 G1 with an exising A@H 2.4 configuration…Worked Perfectly! Thanks for "ALL" of your hard work and I hope that you continue to provide these "Excellent" articles.

    Thanks Again!

  9. Hi Ward: Thanks for a great series of articles on asterisk. BTW, with reference to comment number 7, instructions for using bluetooth as a trunk work only partially – only for dialling calls originating from asterisk and using Cellphone as trunk. They have not worked for me to receive calls into asterisk via bluetooth connected cellphone. Were you able to get it to work bidirectionally?

    [WM: I haven’t messed with this. Bluetooth is so quirky to begin with on the Treo 650 that I doubt it would work in either direction. We need someone with a good Bluetooth phone to wrestle with it.]

  10. Hi Ward!

    Thank you for the "thanks" in "Incoming Fax Support" but in all honesty it is YOU that needs to be acknowledged for your previous article on installing & configuring NVFaxDetect. I used your original faxing guide to configure my setup for incoming faxes & during testing found a few anomalies with the priorities & syntax which I rectified & posted on the Whirlpool forum for others to benefit from.

    The credit is rightfully yours 🙂

    I get my satisfaction from the knowledge that the collaboration & sharing of information helps others who may be less knowledgeable.

    May I take this opportunity to commend you on all the various articles you have written so far, which I take great pleasure in reading & look forward to your future articles.

    Regards,
    Thunderbird 1
    ***Share what you know – Learn what you don’t***

  11. You said you enter your root password into http://192.168.0.108:10000 when prompted. That is a non-routable IP, but doesn’t that seem insecure? Shouldn’t you use https://192.168.0.108:10000? I haven’t tried to install asterisk@home yet but I am about to deploy a bunch of Asterisk systems in production environments. (hints and consulting encouraged) ipstacks @no–spammgmail.com.

    [WM: Yes, it is insecure. Unfortunately, https access isn’t supported in the current default AAH configuration.]

  12. Sorry to be such a pain in the ass, but going through my logs, I found this line…

    Feb 2 08:33:13 NOTICE[4630] pbx.c: Error in extension logic (missing ‘}’)

    it would seem you are missing a } in the fix for max channels, if I’m right. I could be wrong though.

    Thanks for you’re help!

    [WM: You’re not a pain at all. Thanks for catching it. I’ve fixed it in the article.]

  13. Hi Ward.

    With great pleasure i read everytime your articles. Would it be possible to see a full install of all the individual components? (install OS, asterisk, amp, …)

    Also, maybe a tutorial on how to create trunk fallback would be cool. (ex: outbound call goes to trunk1, if thats not available go to trunk2, ….)

    Or what about a more sophisticated dial plan. (Use provider A for calls to landlines, use provider B for calls to Belgian mobiles, use provider C for calls to Italian mobiles, etc)

    Shame on me, so much questions…

    Again, thanks for the great tutorials.

    Eric

  14. In response to the bluetooth. I got it working part ways going both directions. I can call out via the phone no problem. It will answer but gets stuck when I try to ring an extension. I am a very novice aah cat, so I know somebody who knows better can get it to work….

  15. After finishing "The Bleeding Edge" instructions, when I start amportal again…here is what happens.

    [root@asterisk1 src]# amportal start

    SETTING FILE PERMISSIONS
    chown: cannot access `/dev/dsp’: No such file or directory
    Permissions OK

    STARTING ASTERISK
    Asterisk ended with exit status 1
    Asterisk died with code 1.
    Automatically restarting Asterisk.

    —————————————————–
    Asterisk could not start!
    Use ‘tail /var/log/asterisk/full’ to find out why.
    —————————————————–
    [root@asterisk1 src]# tail /var/log/asterisk//full
    Feb 2 23:34:18 VERBOSE[16810] logger.c: == Parsing ‘/etc/asterisk/codecs.conf’: Feb 2 23:34:18 VERBOSE[16810] logger.c: == Parsing ‘/etc/asterisk/codecs.conf’: Found
    Feb 2 23:34:18 VERBOSE[16810] logger.c: — codec_gsm: using generic PLC
    Feb 2 23:34:18 VERBOSE[16810] logger.c: == Registered translator ‘gsmtolin’ from format gsm to slin, cost 4
    Feb 2 23:34:18 VERBOSE[16810] logger.c: == Registered translator ‘lintogsm’ from format slin to gsm, cost 9
    Feb 2 23:34:18 VERBOSE[16810] logger.c: [app_senddtmf.so]Feb 2 23:34:18 VERBOSE[16810] logger.c: [app_senddtmf.so] => (Send DTMF digits Application)
    Feb 2 23:34:18 VERBOSE[16810] logger.c: == Registered application ‘SendDTMF’
    Feb 2 23:34:18 VERBOSE[16810] logger.c: [format_vox.so]Feb 2 23:34:18 VERBOSE[16810] logger.c: [format_vox.so] => (Dialogic VOX (ADPCM) File Format)
    Feb 2 23:34:18 VERBOSE[16810] logger.c: == Registered file format vox, extension(s) vox
    Feb 2 23:34:18 VERBOSE[16810] logger.c: [app_txtcidname.so]Feb 2 23:34:18 WARNING[16810] loader.c: /usr/lib/asterisk/modules/app_txtcidname.so: undefined symbol: option_priority_jumping
    Feb 2 23:34:18 WARNING[16810] loader.c: Loading module app_txtcidname.so failed!

    Do you know why is asterisk dying?

    [WM: I do know why it’s dying (the callerid module won’t load), but I don’t know what caused it. Save yourself a lot of headaches and install Asterisk@Home 2.5 which now includes Asterisk 1.2.4. Here’s our new tutorial.]

  16. ever since 2.1 Centos installs but then asterisk refuses to compile and I’m left with an asterisk1# prompt and nothing else. I’ve tried on an old compaq desktop and a recent dell server and I get the same result. Any help would be much appreciated. thanks – Simon

    [WM: If it’s not a SATA drive, then I’d suspect a bad ISO image or bad CD copy from the image.]

Comments are closed.