Home » Search results for 'sip uri' (Page 54)

Search Results for: sip uri

The Most Versatile VoIP Provider: FREE PORTING

Introducing Asterisk@Home 2.1: Yet Another Soup to Nuts Installation Guide

Want a rock-solid PBX at a rock-bottom price: free! Gosh, you haven't heard that since our column three days ago introducing Asterisk@Home 2.0. You didn't know this was going to be a bi-weekly event, did you? Well, neither did we, but we're happy to oblige when a new release hits the street because it always has something great tucked away inside. Asterisk@Home 2.1 was released two days ago and, from the looks of things, it's another winner! You not only get the latest version of Asterisk® (version 1.2), 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); Digium® card auto-configuration; fax 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 some bug fixes. And there are a few new surprises that we'll get to shortly. Best of all, it amazingly still fits on a single CD!

Editor's Note: This version of Asterisk@Home has been superceded. For the latest tutorial, click here and scroll down the page.

The installation process is pretty straightforward. You download the 2.1 ISO image from here, burn a CD (click here if you need a refresher course), use an old clunker PC or an under $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.20. Here's how the 2.1 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 are about forty of them as we write this 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 update, you'll need to rebuild support for ZAP devices. Log in as root and type rebuild_zaptel. Then reboot. 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.1 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.1 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.1 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.1 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 article on Asterisk@Home 2.0 earlier this week. It fixed a major security flaw in some of WebMin's perl scripts so you'll definitely want this upgrade:

cd /root
mkdir webmin
cd webmin
wget http://internap.dl.sourceforge.net/sourceforge/webadmin/webmin-1.250-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 used to be 10000 to 20000 so there's a conflict on port 10000 with WebMin. Beta 6 fixed this, but version 2.1 doesn't have the change. So, if it still says 10000 on your system, change it to 10001. 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.

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 2.0 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.0 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.

[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. You'll see a couple of ugly error messages. Ignore them. It's a beta bug. Just 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 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 two 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.


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. 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/lib/asterisk/monitor unless you set other preferences in agents.conf.

Fixing Paging. If you want to use paging with your Asterisk system, you'll need to perform a little magic to get it working with your sound card in Asterisk@Home 2.1. For the step-by-step, review this posting on SourceForge. It now works with full and half-duplex sound cards. Thanks, Tracy!

Directory Lookup. 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).

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)


Custom Speed Dialing. Asterisk@Home 2.1 now 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.

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 actual dialplan lines in extensions_custom.conf and reload Asterisk:

; CallingCard application
; un-comment the 5 lines below to use this app
;exten => _X.,1,Answer
;exten => _X.,2,Wait,2
;exten => _X.,3,DeadAGI,a2billing.php
;exten => _X.,4,Wait,2
;exten => _X.,5,Hangup

Footnote: There's also a little missing A2Billing code which needs to be added. You can read all about it here. There's also a pretty good step-by-step setup guide for Asterisk@Home 2.1 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.

Other Out-of-the-Box Utilities. Asterisk@Home 2.1 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. 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 8400. 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 the 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. Enjoy!

Introducing Asterisk@Home 2.0: The Definitive Soup to Nuts Installation Guide

Want a rock-solid PBX at a rock-bottom price: free! Gosh, you haven't heard that since our column a few weeks ago introducing Asterisk® 1.2. What a difference two weeks makes. The final version of Asterisk@Home 2.0 was released the day before Thanksgiving and, from the looks of things, it's darn near perfect! You not only get the latest version of Asterisk (version 1.2), 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 Panel (1.10.010); the Flash Operator Panel (version 0.24); Digium® card auto-configuration; fax support; loads of AGI scripts including weather forecasts and wakeup calls; xPL support; and the SugarCRM Contact Management System with the Cisco XML Services interface and Click-to-Dial support. And it all still fits on a single CD!

NOTE: Version 2.1 was posted late Wednesday, November 30. Our new 2.1 tutorial will be available here on Friday, December 2.

The installation process is pretty straightforward. You download an ISO image from here, burn a CD (click here if you need a refresher course), use an old clunker PC or an under $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 Panel, 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.20. Here's how the 2.0 install went for us, and we'll walk you through the few very minor issues that still remain to be manually tweaked. 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 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 are about forty of them as we write this 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 update, you'll need to rebuild support for ZAP devices. Log in as root and type rebuild_zaptel. Reboot once more and you're all set to go: shutdown -r now.

Simplifying SSH. If you're going to be connecting to other servers from your new Asterisk@Home 2 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 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 Asterisk2 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 2 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:

cd /root
mkdir webmin
cd webmin
wget http://unc.dl.sourceforge.net/sourceforge/webadmin/webmin-1.240-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. 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 used to be 10000 to 20000 so there's a conflict on port 10000 with WebMin. Beta 6 fixed this, but the final version doesn't have the change. So, if it still says 10000 on your system, change it to 10001. 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.

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. The 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 2.0 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.0 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.

[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 and then click the red bar to save your 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. You'll see a couple of ugly error messages. Ignore them. It's a beta bug. Just 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 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 two 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. The easiest one to use is 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 line which begins 127.0.0.1, 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 entries! Save your settings: Ctrl-X, y, enter. Now restart network services on your Asterisk machine: service network restart. Second, 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.


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. If you want to further customize the email message which is sent, just edit vm_email.inc from AMP's Maintenance->Config Edit screen using your favorite web browser. 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.

Fixing Call Recording. This link explains the process as well as we could. After making the two changes, call recording inbound and outbound works reliably.

Fixing Paging. If you want to use paging with your Asterisk system, you'll need to perform a little magic to get it working with your full duplex sound card in Asterisk@Home 2.o. For the step-by-step, review this posting on SourceForge.

Fixing Directory Lookup. Usually, pressing the pound key (#) from any phone connected to your Asterisk server calls up a directory lookup function using the Asterisk Management Portal (AMP); however, Digium renamed one of the voice prompts in the 1.2 release of Asterisk which broke this function in AMP. If you simply log into your server as root and issue the following command, it will create a symbolic link to the renamed file and will permanently fix the problem:

ln -s /var/lib/asterisk/sounds/dir-intro-fn.gsm /var/lib/asterisk/sounds/dir-intro-oper.gsm

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->extension.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)

Where To Go From Here. Once you've got a functioning Asterisk system, you're ready to move on to the 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. Enjoy!

Keeping Telemarketers At Bay with Asterisk

Just when you thought the National Do-Not-Call Registry was getting you some peace and quiet during the dinner hour, VoIP telephony comes along to give the telemarketers a brand new universe to pollute. And, of course, the politicians exempted themselves and non-profits from the Do-Not-Call rules anyway. Thanks to Katrina and local elections in November, you can expect a wave of unwanted dinnertime calls from your best friends at campaign headquarters or the Fraternal Order of Police. Lucky for you, there's an Asterisk® PBX standing between the telemarketers and your dinner table. Here are a few simple additions you can make to your Asterisk PBX setup to all but eliminate unwanted callers from your life. There are three types of protection we'll address. First, you can build a separate context to handle callers without CallerID. Second, you can send a special information tone to certain callers to block autodialers. And finally, when all else fails, you can quickly place certain numbers in a BlackList database to make sure it's the last time that folks using that number ever disturb you again.

Managing CallerID-less Callers. Not all callers without a CallerID name and number are bad people, at least not quite. So we want to structure our treatment of calls without CallerID in such a way that we don't discard a call that might be important. There are a couple of things you can do to manage these calls. First, you can have Asterisk prompt such callers to either say their name or to key in their phone number. Our preference is recording the name of the caller because hearing the caller speak gives you a good idea whether you want to take the call whereas asking a caller to enter their phone number does nothing to deter really obnoxious telemarketers. With either of these options, our approach (which we previously covered in our security column) is to prompt the caller for the information, park the caller with music on hold, and then announce the call and play back either the caller's name or number. You then have the option of picking up the parked call or leaving the caller parked until they're automatically disconnected.


Our other recommendation for calls without CallerID is to send a special information tone when the call is answered. For those of you that spent $40 on a Telezapper, we're sorry. Asterisk can do it for free. And it really does work with many autodialers used by telemarketers. In fact, with most such systems, once the autodialer receives the special information tone, it places your number in their do-not-call database so you'll never be bothered again. Here's the code we previously recommended to handle calls without CallerID. First, for Asterisk@Home users and others using the Asterisk Management Portal, you tell Asterisk to send incoming calls to your AutoAttendant context. Of all the Asterisk@Home problems we read about, the number 1 issue hands down is incoming calls either ringing with a fast busy or being dropped immediately into voicemail. You fix both problems by deleting the current contents of your [from-sip-external] context and adding the following GoTo command to the [from-sip-external] context in the extensions.conf file. This will send incoming callers to your AutoAttendant (shown below).

exten => _.,1,Wait(1)
exten => _.,2,Goto(from-external-custom,s,1)

And then you drop the following AutoAttendant context into the bottom of your extensions_custom.conf config file. As we've mentioned before, if you cut-and-paste the code below, you'll need to manually replace the typographic quotation marks with regular quote marks, or Asterisk gets sent into the ozone.

[from-external-custom]
exten => s,1,Zapateller(answer|nocallerid)
exten => s,2,Wait(1)
exten => s,3,SetMusicOnHold(default)
exten => s,4,GotoIf($["${CALLERIDNUM}" = ""]?who-r-u,s,1)
exten => s,5,GotoIf($["foo${CALLERIDNUM}" = "foo"]?who-r-u,s,1)
exten => s,6,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?who-r-u,s,1)
exten => s,7,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?who-r-u,s,1)
exten => s,8,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
exten => s,9,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)
exten => s,10,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?who-r-u,s,1)
exten => s,11,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
exten => s,12,DigitTimeout,3
exten => s,13,ResponseTimeout,3
exten => s,14,Background(custom/welcome)

exten => 0,1,Background(pls-hold-while-try)
exten => 0,2,AGI(directory,general,ext-local,${DIRECTORY:0:1}${DIRECTORY_OPTS})
exten => 0,3,VoiceMail(204@default) ; this assumes extension 204 is where you want your voicemail to land
exten => 0,4,Hangup
exten => 1,1,Background(pls-hold-while-try)
exten => 1,2,Dial(local/222@from-internal,20,m) ; we use extension 222 as a ring group to call ALL phones
exten => 1,3,VoiceMail(204@default)
exten => 1,4,Hangup
exten => 4,1,Authenticate(1234588)
exten => 4,2,Background(pls-wait-connect-call)
exten => 4,3,DISA(no-password|from-internal)

exten => 2XX,1,Background(pls-hold-while-try)
exten => 2XX,2,Dial(local/${EXTEN}@from-internal,20,m)
exten => 2XX,3,VoiceMail(${EXTEN}@default)
exten => 2XX,4,Hangup
exten => 2XX,103,Voicemail(${EXTEN}@default)
exten => 2XX,104,Hangup

exten => t,1,Background(pls-hold-while-try)
exten => t,2,Dial(local/204@from-internal,20,m)
exten => t,3,VoiceMail(204@default)
exten => t,4,Hangup

exten => o,1,Dial(local/204@from-internal,20,m) ; this is where pressing 0 takes the caller
exten => o,2,VoiceMail(204@default)
exten => o,3,Hangup

exten => i,1,Playback(wrong-try-again-smarty)
exten => i,2,Goto(s,16)

And finally you add the following two contexts to the bottom of the extensions_custom.conf file to handle the unidentified callers. The extension to ring to announce unidentified callers (204 in this example) is in line 70,5 below.

[who-r-u]
exten => s,1,Background(privacy-unident)
exten => s,2,Background(vm-rec-name)
exten => s,3,Wait(2)
exten => s,4,Record(/tmp/asterisk-stranger:gsm|5|15)
exten => s,5,Background(pls-hold-while-try)
exten => s,6,Goto(ext-park,70,1)
exten => s,7,VoiceMail(204@default)
exten => s,8,Playback(Goodbye)
exten => s,9,Hangup

[ext-park]
exten => 70,1,Answer
exten => 70,2,SetMusicOnHold(default)
exten => 70,3,SetCIDNum(200|a)
exten => 70,4,SetCIDName(Parked Call Info|a)
exten => 70,5,ParkAndAnnounce(silence/9:asterisk-friend:/tmp/asterisk-stranger:vm-isonphone:at-following-number:PARKED|40|local/204@from-internal|who-r-u,s,7)
exten => 70,6,Hangup

A footnote to all of this technology is that we personally receive so few legitimate calls from callers without CallerID that we've modified the [who-r-us] context to simply send all these callers straight to voicemail. We'll get a phone alert and an email whenever a new voicemail arrives so, if it's some sort of emergency, we can respond by returning the call immediately. Haven't seen one yet!

BlackListing. And then there are the smart telemarketers, and we'd put the Baby Bells at the top of this list. These are organizations that intentionally provide a fictitious CallerID number just to get around systems that block calls with no CallerID. They're still selling something, and they're just as annoying. They slip into your home under an exception to the Do-Not-Call Registry for "calls from organizations with which you have established a business relationship." In other words, if you buy local phone or cable TV service, these folks have a blank check to annoy the hell out of you ... forever! That's their interpretation of the statute anyway.


As luck would have it, Asterisk@Home 1.5 handles blacklisting callers using its internal database (ast_db) so you never have to take another annoying call from them. Just pick up your phone after an unwanted call, and press *32. That's it. Not much in what follows is original by the way. Our special thanks to Jacken's Blog for documenting all of this. All we've done is revise their code a bit to make it fit the configuration laid out in our other Asterisk@Home tutorials. Note also that problems have been reported using this code with the Asterisk@Home 2.0 betas, but we'll address that down the road as well. To implement BlackListing, we're going to add a line at the top and bottom of our AutoAttendant code and then renumber the 's' extension commands. We also need to adjust the pointer on line i,2 to goto s,17. So the new code looks like this. The way the LookupBlacklist command works is that, if a CallerID number is found in the BlackList database, execution jumps to line s,104 (3 + 101). From there, we send the call to a "special" context to handle blacklisted callers.

[from-external-custom]
exten => s,1,Zapateller(answer|nocallerid)
exten => s,2,Wait(1)
exten => s,3,LookupBlacklist ; If CID blacklisted, goto 104
exten => s,4,SetMusicOnHold(default)
exten => s,5,GotoIf($["${CALLERIDNUM}" = ""]?who-r-u,s,1)
exten => s,6,GotoIf($["foo${CALLERIDNUM}" = "foo"]?who-r-u,s,1)
exten => s,7,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?who-r-u,s,1)
exten => s,8,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?who-r-u,s,1)
exten => s,9,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
exten => s,10,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)
exten => s,11,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?who-r-u,s,1)
exten => s,12,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
exten => s,13,DigitTimeout,3
exten => s,14,ResponseTimeout,3
exten => s,15,Background(custom/welcome)
exten => s,104,Goto(custom-blacklisted,s,1)

exten => 0,1,Background(pls-hold-while-try)
exten => 0,2,AGI(directory,general,ext-local,${DIRECTORY:0:1}${DIRECTORY_OPTS})
exten => 0,3,VoiceMail(204@default)
exten => 0,4,Hangup
exten => 1,1,Background(pls-hold-while-try)
exten => 1,2,Dial(local/222@from-internal,20,m)
exten => 1,3,VoiceMail(204@default)
exten => 1,4,Hangup
exten => 4,1,Authenticate(1234588)
exten => 4,2,Background(pls-wait-connect-call)
exten => 4,3,DISA(no-password|from-internal)

exten => 2XX,1,Background(pls-hold-while-try)
exten => 2XX,2,Dial(local/${EXTEN}@from-internal,20,m)
exten => 2XX,3,VoiceMail(${EXTEN}@default)
exten => 2XX,4,Hangup
exten => 2XX,103,Voicemail(${EXTEN}@default)
exten => 2XX,104,Hangup

exten => t,1,Background(pls-hold-while-try)
exten => t,2,Dial(local/204@from-internal,20,m)
exten => t,3,VoiceMail(204@default)
exten => t,4,Hangup

exten => o,1,Dial(local/204@from-internal,20,m)
exten => o,2,VoiceMail(204@default)
exten => o,3,Hangup

exten => i,1,Playback(wrong-try-again-smarty)
exten => i,2,Goto(s,17)

Now we need to drop in four BlackList contexts to let you respond to BlackListed callers and to manage your BlackList process using any touchtone phone. So, at the bottom of the extensions_custom.conf file, add the following:

[custom-blacklist-last]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,DBget(number=CALLTRACE/${CALLERIDNUM}) ; goto 104 if no lastcaller
exten => s,4,GotoIf($"${number}" = ""?104) ; also if it's blank (caller id blocked)
exten => s,5,Playback(privacy-to-blacklist-last-caller)
exten => s,6,Playback(telephone-number)
exten => s,7,SayDigits(${number})
exten => s,8,Wait,1
exten => s,9,Background(press-1)
exten => s,10,Background(or)
exten => s,11,Background(press-star-cancel)
exten => s,12,Hangup
exten => s,104,Playback(unidentified-no-callback)
exten => s,105,Background(goodbye)
exten => s,106,Hangup
exten => 1,1,DBput(blacklist/${number}=1)
exten => 1,2,Playback(privacy-blacklisted)
exten => 1,3,Wait,1
exten => 1,4,Background(goodbye)
exten => 1,5,Hangup
exten => t,1,Background(goodbye)
exten => t,2,Hangup
exten => i,1,Background(goodbye)
exten => i,2,Hangup
exten => o,1,Background(goodbye)
exten => o,2,Hangup

[custom-blacklist-add]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Playback(enter-num-blacklist)
exten => s,4,ResponseTimeout(30)
exten => s,5,Read(blacknr,then-press-pound)
exten => s,6,SayDigits(${blacknr})
exten => s,7,Playback(if-correct-press)
exten => s,8,Playback(digits/1)
exten => s,9,Hangup
exten => 1,1,DBput(blacklist/${blacknr}=1)
exten => 1,2,Playback(num-was-successfully)
exten => 1,3,Playback(added)
exten => 1,4,Wait(1)
exten => 1,5,Hangup

[custom-blacklist-remove]
exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Playback(entr-num-rmv-blklist)
exten => s,4,DigitTimeout(5)
exten => s,5,ResponseTimeout(30)
exten => s,6,Read(blacknr,then-press-pound)
exten => s,7,SayDigits(${blacknr})
exten => s,8,Playback(if-correct-press)
exten => s,9,Playback(digits/1)
exten => s,10,Hangup
exten => 1,1,DBdel(blacklist/${blacknr})
exten => 1,2,SayDigits(${blacknr})
exten => 1,3,Playback(num-was-successfully)
exten => 1,4,Playback(removed)
exten => 1,5,Hangup

[custom-blacklisted]
exten=>s,1,Answer
exten=>s,2,Wait(1)
;exten=>s,3,Playback(nbdy-avail-to-take-call)
;exten=>s,4,Playback(carried-away-by-monkeys)
;exten=>s,5,Playback(lots-o-monkeys)
exten=>s,3,Background(tt-allbusy)
exten=>s,4,SetMusicOnHold,default
exten=>s,5,WaitMusicOnHold,30
exten=>s,6,Background(thank-you-for-calling)
exten=>s,7,Background(goodbye)
exten=>s,8,Congestion
exten=>s,9,Hangup

The [custom-blacklist-last] chunk of code automatically adds the phone number of your last incoming call to your BlackList. The [custom-blacklist-add] context lets you manually add a number to your BlackList. The [custom-blacklist-remove] context lets you remove a number that's already in your BlackList. And the [custom-blacklisted] context actually processes incoming callers who are on your BlackList. As currently written, the caller will get a message that "all members of the household are currently assisting other telemarketers ..." followed by music on hold. After 30 seconds, they are kissed goodbye with a congestion tone. I've also commented out the Jacken's Blog approach which is equally annoying. So take your pick.


The only remaining step to get all this working is to designate some extensions that will be dialed to access the three custom BlackList management contexts above. These need to be placed within the [from-internal-custom] context of your extensions_custom.conf file. Feel free to make up your own extension numbers so long as they don't conflict with existing extensions on your system. And be sure to change the Authenticate password in each of the three lines below. Once you add the extensions, reload Asterisk and BlackList someone you love... or at least someone you used to love.

exten => *30,1,Authenticate(45678)
exten => *30,2,Goto(custom-blacklist-add,s,1)

exten => *31,1,Authenticate(45678)
exten => *31,2,Goto(custom-blacklist-remove,s,1)

exten => *32,1,Authenticate(45678)
exten => *32,2,Goto(custom-blacklist-last,s,1)

exten => *33,1,Goto(custom-blacklisted,s,1)

How To Review Your BlackList. One final piece remains for our puzzle today. At some point down the line, you may want to review every number that's been entered into your BlackList. Here's how. Using SSH or Putty, connect to your Asterisk server and log in as root. Start up the Asterisk Command Line Interface (CLI) with the command asterisk -r. Now enter the following command at the asterisk*CLI> prompt: database show blacklist. You can manually delete an entry while you're here with the command: database del blacklist 0123456789 1. Don't forget the trailing 1. To manually add an entry to the database, enter the command: database put blacklist 0123456789 1.

You're an expert now. So just sit back and wait for the Bad Guys to call. They will.


Some Recent Nerd Vittles Articles of Interest...

Putting Real Names Back in CallerID: 3 Quick Perl Solutions for the Asterisk PBX

If you haven't noticed, useful Caller ID (meaning a number and a name display) is pretty much a bust in the VoIP marketplace except for calls originating from Baby Bell-controlled local phone numbers. And, with some VoIP providers, getting a CallerID name with any incoming call is a rarity. Jeff Pulver has proposed a new national database where you can list yourself. In fact, you can sign up today. But, suffice it to say, it isn't soup just yet. Known in the trade as CNAM service, many telephony service providers simply throw incoming names in the bit bucket unless you are one of their subscribers. The Baby Bells are among the most notorious. Some don't even provide CNAM service from other areas of the country unless the caller is part of the local carrier's feifdom. And I guess if I charged $40 for basic local phone service with CallerID, I'd want to keep my monopoly, too. We'll have more on the pricing issue at the end of today's article.

2008 Update. For the latest in CallerID name lookup software written in PHP, visit our Best of Nerd Vittles site. For PBX in a Flash users that want a Perl version, check out the PBX in a Flash Forum.

For those of you wrestling with Caller ID on your Asterisk® PBX, we have three solutions today and more to come. Today's perl AGI utility was developed initially by Tom Vile at Baldwin Technology Solutions. Tom has graciously agreed to let us share the code with you. Thanks, Tom! It lets you intercept incoming calls to your Asterisk box and pass the CallerID number to AT&T's AnyWho.com for a reverse number lookup to decipher the CallerID name. Whether this comports with the AnyWho terms of service, we'll leave for you to resolve. Suffice it to say, the "phone company" has always maintained that the phone book information is copyrightable. And the Supreme Court of the U.S. has held just the opposite. This is not legal advice, just some historical background for you to digest before proceeding.


Once we started looking at Tom's code, we decided it might be a good time to learn Perl so you've been forewarned that nothing in the solutions which follow will qualify as elegant coding other than Tom's original handiwork, of course. But the stuff does work. What we've added to Tom's original code are two enhancements. First, you can opt to use Google for reverse number lookup if you'd like. And second, you can tie reverse number lookups into the AsteriDex web-based MySQL database application which we previously built and which you can download and use for free here. Particularly for home and small business use, the universe of incoming callers is fairly small so you may find that AsteriDex is the best solution. This is particularly true if many of your incoming calls are from cell phones since few of the American carriers associate real names with their CallerID numbers. Some do provide the city of the caller in the CallerID name. Others refer to us all as Wireless Caller(s). Gee, what a hint. Consequently, neither AnyWho nor Google have many cell phone numbers in their databases. Call it a feature. The bottom line is you can mix and match AnyWho, Google, and AsteriDex lookups as you see fit by simply setting "on" and "off" flags for each of the three services.

Footnote: As of November 13, we've added another lookup function for FoneFinder.net. This one's a little different in that it returns the city and provider type for phone numbers matching the area code and first three digits of the caller's number. It also has the lowest precedence and can be activated to at least return the city name and provider type for callers where no other information is available from the other services.

Overview. The way this works is that incoming calls will be processed through an AGI script that you configure with your lookup preferences. We recommend you use this script with Asterisk@Home because it comes bundled with all the MySQL, Apache, PHP, and Perl stuff you'll need to make everything work. The script as received does nothing since all three lookups are disabled. That lets you choose which services to activate and conveniently moves the legal monkey from our back to yours. Didn't go to law school for nothing, did we? Assuming you turn on all three lookups, the AnyWho lookup is processed first. If a match is found, the Caller ID name is added to the existing Caller ID number replacing whatever name entry already was picked up for the incoming call. If no match is found, the existing CallerID number and name are left as they were received for the incoming call. The CallerID number is then passed to the Google phonebook where the process is repeated. If there's a match, the CallerID name is replaced with the name found in the Google search. If not, nothing changes. Finally, if you're using AsteriDex as your personal phone book, the CallerID number will be looked up in your AsteriDex database. If there's a match, whatever you entered as the name for the first matching phone number entry will be picked up as the CallerID name for the call ... so these names can be as obnoxious as you choose to make them. Note that the AsteriDex lookup is a crude search. If you've entered the same phone number for three different people in the same house, then only the first one it finds will be used. You'll know which one it is when you receive the first call from this number. So, the bottom line is this: AsteriDex lookups take precedence over Google and AnyWho lookups, and Google lookups take precedence over AnyWho lookups. And, at least for the short term, if you want any meaningful information about cell phone callers and most VoIP callers, you'll need to put their names and numbers in your AsteriDex database.


To get started, download the calleridname.agi script from here. Then copy it to the /var/lib/asterisk/agi-bin folder on your Asterisk server. Log in to your Asterisk server as root and change the ownership of the file: chown asterisk:asterisk /var/lib/asterisk/agi-bin/calleridname.agi. And change the permissions: chmod 775 /var/lib/asterisk/agi-bin/calleridname.agi. To activate the services you want to use, edit the calleridname.agi script: nano -w /var/lib/asterisk/agi-bin/calleridname.agi. CAUTION: Before you open the file with nano, be sure your editing window is at least 180 characters wide unless you use the -w switch, or some of the commands in the file will be truncated. Then nothing works! Nano doesn't do word wrap in a Perl-friendly way if left to its own devices. Once you open the file, beginning on line 10, you'll see the following entries:

$Fonetastic = '0' ;
$AnyWho = '0' ;
$Google = '0' ;
$Asteridex = '0' ;

For each service you want to activate, change the '0' to '1' and then save the file: Ctrl-X, Y, then press Enter key. Now we're ready to reconfigure your incoming call dialplan.

If you've been following along with our other tutorials, you should already have the Stealth AutoAttendant in place to handle your incoming calls. If not, start there ... or you're on your own. After making the security modifications, here's how our autoattendant code looks in the extensions_custom.conf config file:

[from-external-custom]
exten => s,1,Zapateller(answer|nocallerid)
exten => s,2,Wait(1)
exten => s,3,SetMusicOnHold(default)
exten => s,4,GotoIf($["${CALLERIDNUM}" = ""]?who-r-u,s,1)
exten => s,5,GotoIf($["foo${CALLERIDNUM}" = "foo"]?who-r-u,s,1)
exten => s,6,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?who-r-u,s,1)
exten => s,7,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?who-r-u,s,1)
exten => s,8,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
exten => s,9,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)
exten => s,10,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?who-r-u,s,1)
exten => s,11,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
exten => s,12,DigitTimeout,3
exten => s,13,ResponseTimeout,3
exten => s,14,Background(custom/welcome)

We're going to introduce another new trick in the incoming dial plan. What we want to do is answer the call, do some processing, and then pass the call to where it's supposed to go. The trick is that we don't want the caller to know we've already answered the call while we're doing the processing. So what we're going to do is play a fake ringing tone to the caller so the caller doesn't get bored. Just insert a new third line in the dialplan that looks like this: exten => s,3,Playtones(ring) and then renumber the remaining lines. Next we want to add our new CallerIDName lookup immediately before the custom/welcome message plays: exten => s,17,AGI(calleridname.agi) and then renumber the lines. When you're all finished, your code should look like this:

[from-external-custom]
exten => s,1,Zapateller(answer|nocallerid)
exten => s,2,Wait(1)
exten => s,3,Playtones(ring)
exten => s,4,SetMusicOnHold(default)
exten => s,5,GotoIf($["${CALLERIDNUM}" = ""]?who-r-u,s,1)
exten => s,6,GotoIf($["foo${CALLERIDNUM}" = "foo"]?who-r-u,s,1)
exten => s,7,GotoIf($["${CALLERIDNAME:0:9}" = "Anonymous"]?who-r-u,s,1)
exten => s,8,GotoIf($["${CALLERIDNAME:0:7}" = "Unknown"]?who-r-u,s,1)
exten => s,9,GotoIf($["${CALLERIDNUM:0:7}" = "Private"]?who-r-u,s,1)
exten => s,10,GotoIf($["${CALLERIDNAME:0:7}" = "Private"]?who-r-u,s,1)
exten => s,11,GotoIf($["${CALLERIDNUM:0:10}" = "Restricted"]?who-r-u,s,1)
exten => s,12,GotoIf($["${CALLERIDNUM:0:4}" = "PSTN"]?who-r-u,s,1)
exten => s,13,DigitTimeout,3
exten => s,14,ResponseTimeout,3
exten => s,15,AGI(calleridname.agi)
exten => s,16,Background(custom/welcome)

Remember that, if you cut-and-paste the code above, you'll need to manually fix the typographic quotation marks to make them regular quote marks that Asterisk can understand or disaster awaits. Once you save your changes and reload Asterisk, you should be good to go. Start up the Asterisk Command Line Interface (CLI) and make a test call to yourself. You should see something like this in the CLI display:

calleridname.agi: CALLERID IS: 3035551616 <3035551616>
calleridname.agi: Checking 303 555 1616...
calleridname.agi: Fonetastic.US lookup disabled.
calleridname.agi: AnyWho lookup disabled.
calleridname.agi: Ready for Google lookup...
calleridname.agi: Google match. New CallerIDName = R. Smith
calleridname.agi: Ready for AsteriDex lookup...
calleridname.agi: AsteriDex match. New CallerIDName = Robbie the Nerd

Money-Saver Tip of the Week. We regularly hammer BellSouth and the other RBOCs for their pricing policies on home phone service so it's great to finally have something nice to say about our hometown company. Actually, BellSouth might not think this is too nice, but we sure do. A post on DSL Reports this week had this helpful tip for those with BellSouth DSL service that would prefer not to keep paying $40 a month for a BellSouth phone line you never use. You can suspend your phone service for up to six months and reduce your monthly line costs by 50% or more while still retaining your $24.95 DSL service through BellSouth. You can even get a recorded message referring callers to your new [VoIP] number at no charge. For details, visit this BellSouth link. To put things in proper perspective, this means you can suspend your BellSouth line, order two new TelaSIP VoIP lines with unlimited U.S. long distance on both lines for $14.95 a month, notify your BellSouth callers of your new number, and still put $5 in the bank each month compared to what you're paying BellSouth today for just one line with pay-through-the-nose long distance access. Now that's a sweet deal! For those that are curious, a garden-variety residential line from BellSouth in Atlanta with nothing other than CallerID and dial tone runs $39.75 per month with tip and taxes, and I've got this month's statement to prove it. Does it take a collision with a freight train for the RBOCs to wake up before all their residential customers have jumped ship just like their pay phone customers did? Probably so.


Sony Anyone? Just Say No! If you missed the latest attack on your home computer this week, don't worry. It wasn't a malicious virus creator this time. It's S-O-N-Y. Before you spend another dime with Sony, read this C|NET article. Here's a brief snippet:

"You buy a CD. You put the CD into your PC in order to enjoy your music. Sony grabs this opportunity to sneak into your house like a virus and set up camp, and it leaves the backdoor open so that Sony or any other enterprising intruder can follow and have the run of the place. If you try to kick Sony out, it trashes the place. And what does this software do once it's on your PC ..."

Other Asterisk Tutorials. There are numerous additional articles in this Asterisk HOW-TO series to keep you busy. You can read all of them by clicking here and scrolling down the page. We recommend reading at least the first four or five articles from the bottom up so that the learning curve is less painful. Then you can skip around to your heart's content.

Follow-Me Phoning: Implementing Bluetooth Proximity Detection with Asterisk, Part III

This is the third and final article in our series showing how to deploy a Bluetooth Proximity Detection system with your Asterisk@Home PBX. Parts I and II are here. Today we finish up and activate everything so that your Asterisk® PBX system will track your whereabouts and automatically transfer incoming calls in your home or office to your cellphone or any other phone whenever you leave home base carrying your bluetooth-enabled cellphone or your bluetooth headset. And, when you return, calls automatically will begin flowing to your local extensions just as they did before you left your home or office. For our Mac users, we'll have a follow-up article some day soon showing you how to tie proximity detection into the home automation server we previously built with Indigo. Then, as you arrive home in the evening, you can turn on your lights, and stereo, and hot tub just by pulling up in front of your house with your Bluetooth headset or cellphone.

NOTE: This article has been updated to take advantage of TrixBox, freePBX, and the iPhone. For the current article, click here.

Last week we showed you how to use your new Asterisk@Home 2 PBX machine to detect the presence or absence of your bluetooth phone or headset. And we used freely available open source tools for Linux to do the tracking. Our game plan for today is to show you how to relay that information from your Bluetooth Proximity Detection system to your main Asterisk system in real time. And then we'll modify the dialplan on your main Asterisk system a bit so that it intelligently routes incoming calls after first deciphering whether you are IN or OUT of your home or office. For purposes of this tutorial, we're assuming that you have taken our advice and implemented a second Asterisk@Home server (the version 2 beta) to take advantage of the bundled CentOS/4 Linux operating system. Our design also assumes that both your main Asterisk machine and your new Asterisk proximity detection system are both behind the same firewall on the same internal network. So we'll begin today by finishing the detection tasks on the new Asterisk server, and then we'll turn our attention to your primary Asterisk server, i.e. the system that takes and makes your phone calls. Update: Now that Asterisk@Home 2.1 is shipping, you may decide you'd prefer to deploy this entire system on a single server. If so, print this article and then go here for the instructions needed for a single server deployment.


Overview of Bluetooth Proximity Detection Design. If you've been following along with the two previous articles in this series, then you already have your Asterisk@Home 2 PBX server running with full Bluetooth support. If not, start there. The real trick to making Bluetooth Proximity Detection work for this project was using hcitool name 00:03:89:43:84:e2 with the actual MAC address of your Bluetooth headset or phone. This utility returns a null string if the Bluetooth device is not found and returns the name of the device if it is found. We'll take advantage of that information to drive our proximity detection system by simply writing the results of this test to a text file once a minute. We then can use a Linux bash script to execute a certain action based upon whether your Bluetooth device is IN range or OUT of range. As usual, we've chosen the easy way. So our plan is to copy a null file to your primary Asterisk server when you're OUT, and we'll copy a one-byte file to your primary Asterisk server when you're IN. Then we can run a similar script on the primary Asterisk server to check whether you're IN or OUT each time a phone call arrives. We'll only upload the null or one-byte file when the status changes to keep the processing load low. If you want to track multiple people with multiple Bluetooth devices, then rename the ruhome file to include the name of the person that's carrying the device, e.g. wardruhome. Then it'll be easy to implement this for multiple people. Just repeat the steps.

Configuring Files for Asterisk 2 Server. The files we'll be using in our Proximity Detection System can be downloaded here and unzipped into the proximity folder on your Desktop. Don't modify null.file or notnull.file because doing so will probably change their file sizes, and then none of this works. We are depending upon the notnull.file remaining a zero byte file! You do need to edit the ruhome file whether you rename it or not. Call it up with a text editor and modify the following settings to match your configuration:

mainasteriskbox=192.168.0.104
deviceuser=WARD
devicemac=00:03:89:43:84:e2

We recommend upper case letters for the deviceuser just so it will be easy to identify. The devicemac is the MAC address of your Bluetooth device to be monitored. And mainasteriskbox is the private IP address of your main Asterisk server. Once you make these changes, save the file in text-only format and then copy the following three files in the proximity folder to the /root directory on your Asterisk2 Proximity Detection Server: ruhome, null.file, and notnull.file. Then log in to your Asterisk2 server as root, and move to the /root folder: cd /root. Now adjust the file permissions on script you put there substituting the name you gave your script: chmod 775 ruhome.


If you read through the ruhome script, you'll notice that it copies either null.file or notnull.file to your primary Asterisk server whenever there's a change in the presence of your bluetooth device, and it names the file to match the assigned deviceuser. To make the copy process work, we need to use the scp utility that is bundled with Linux. There's only one wrinkle. SCP prompts for a password whenever you attempt to log in to your other Asterisk box, and that would preclude our being able to handle this as a background job with no user interaction. Luckily, there's a simple solution: a public/private key pair. If you want the complete tutorial, go here. Otherwise, just do the following. Log in to your new Asterisk@Home 2 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 main Asterisk server from your secondary Asterisk2 server using SCP. The command should look like the following (except use the private IP address of your primary Asterisk server instead of 192.168.0.104). Provide the root password to your primary Asterisk server when prompted to do so.

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

Once the file has been copied, let's try to log in to your primary Asterisk server from your Asterisk 2 Proximity Server with the following command using the correct 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 primary server by typing exit.

The final step on the Asterisk2 Proximity Server is to schedule this script to run once a minute to keep track of your comings and goings. While still logged in as root, issue the following commands:

export EDITOR=nano
crontab -e

This will start up the Crontab utility using our favorite editor, Nano. Now enter the command below substituting the correct name of your script:

* * * * * /root/ruhome > /dev/null

If you'd prefer to only run the script every minute between 6 in the morning and 9 at night, the code would look like what's shown below. Just choose the hours desired and remember that your IN and OUT status will be frozen at the exact moment the script completes its run at 8:59 p.m. if you use the settings below. And it won't check your bluetooth proximity again until 6:00 a.m. tomorrow morning.

* 6-21 * * * /root/ruhome > /dev/null

Once you've gotten the entry the way you want it using the actual name of the script you placed in the root folder, save your crontab entry: Ctrl-X, Y, and press Enter key. Now turn on your Bluetooth device and move it within range of your Asterisk2 server, count to 60, and then check the /tmp folder on your primary Asterisk server for a file with the name you specified for deviceuser above, e.g. ls -all /tmp/WARD. The size of the file should be 1 indicating that your specified Bluetooth device is within range of your Asterisk2 server. Now turn the Bluetooth device off and wait another minute or two. Repeat the steps above and make sure the file size has shrunk to 0. When all this works according to plan, you're ready to move on and configure your primary Asterisk server to manage your incoming calls based upon whether you're IN or OUT.


Configuring Your Main Asterisk Server for Proximity Detection. As you learned above, the Asterisk2 proximity detection server will actually do the heavy lifting by figuring out when you're IN and when you're OUT. It then will upload the appropriate file to your primary Asterisk server when your status changes. But we'll still need a little script on your primary Asterisk server to actually check your status whenever an incoming call arrives. That's the job of the homecheck.agi script in the proximity folder you downloaded. Before it will work, the deviceuser specified at the top of this file must match the name you assigned to deviceuser in the ruhome script. So edit the homecheck.agi script and then save the file as plain text. Then copy it to /var/lib/asterisk/agi-bin on your primary Asterisk server. Log in to that server as root and change the ownership of this file: chown asterisk:asterisk /var/lib/asterisk/agi-bin/homecheck.agi. And then set the permissions: chmod 775 /var/lib/asterisk/agi-bin/homecheck.agi.

The remaining tasks on the primary Asterisk server we'll handle using the Asterisk Management Portal (AMP) so, using your favorite web browser, connect to the primary Asterisk server and then choose AMP->Maintenance->Config Edit and click on extensions_custom.conf. If you're using our Stealth Autoattendant, then locate the code in your extensions_custom.conf file. All that we need to modify is the timeout section of the code: exten=>t. So you'll still be able to take advantage of your AutoAttendant even when you're away from your home or office. Here's what we are using:

exten => t,1,Background(pls-hold-while-try)
exten => t,2,AGI(homecheck.agi)
exten => t,3,GotoIf($["${WARD:0:2}" = "OU"]?custom-outhouse,s,1:4)
exten => t,4,Dial(local/222@from-internal,20,m) ; Ring group 222 dials all phones
exten => t,5,VoiceMail(204@default) ; Default voicemail account for your home
exten => t,6,Hangup

NOTE: You can't cut and paste the above code unless you manually change the typographic quotation marks in the third line to normal quotes that Asterisk understands. There are two sets of them! Also change WARD to the deviceuser name you assigned above in your script files. The final piece of code you'll need is the context to actually process the incoming calls when you are out of the house or office, custom-outhouse. Just cut-and-paste it to the bottom of extensions_custom.conf. As usual, you can customize it to your heart's content, but here are a couple ideas from our own system. Once you're finished, save your changes and then reload Asterisk.

[custom-outhouse]
;exten => s,1,Dial(SIP/6781234567@telasip-gw,60,m) ; This approach just quietly sends callers to your cell phone using the telasip-gw trunk
;exten => s,2,VoiceMail(204@default)
;exten => s,3,Hangup

exten => s,1,Wait(1) ; This approach plays a custom message which we previously showed you how to do. Here's the message:
exten => s,2,Background(custom/nothome) ; No one's home. To try our cellphones, press 1 for Mary or 2 for Ward. Or press 3 to leave a message.
exten => s,3,DigitTimeout,4
exten => s,4,ResponseTimeout,5
exten => t,1,VoiceMail(204@default)
exten => t,2,Hangup
exten => i,1,Playback(wrong-try-again-smarty)
exten => i,2,Goto(s,1)
exten => o,1,VoiceMail(204@default) ; if the caller presses 0, then it's off to voicemail they go
exten => o,2,Hangup
exten => h,1,Hangup
exten => 1,1,Background(pls-hold-while-try)
exten => 1,2,Dial(SIP/6781234567@telasip-gw,60,m)
exten => 1,3,VoiceMail(204@default)
exten => 1,4,Hangup
exten => 2,1,Background(pls-hold-while-try)
exten => 2,2,Dial(SIP/6782345678@telasip-gw,60,m)
exten => 2,3,VoiceMail(204@default)
exten => 2,4,Hangup
exten => 3,1,VoiceMail(204@default)
exten => 3,2,Hangup

Well, that should do it. Once you restart your Asterisk server, you can place a call to your home while you're IN and while you're OUT carrying your Bluetooth device to make sure things are doing what they should. Now all you have to do is to remember to recharge your Bluetooth device each night. Enjoy!

There's now a fourth article in this series which you can read by clicking here.

Coming Attractions. No, we haven't forgotten. We still have our incoming fax server to build, and we want to start using Asterisk's built-in Blacklist database tools. Then we'll be turning our attention to using SSH and SCP to build automated backups of your primary Asterisk server using the password trick we learned in the proximity detection article today. And now that you have a second Asterisk server, you might as well learn how to connect them together so that you can make calls to extensions on either server and make outgoing calls using either server. So stay tuned!

Other Asterisk Tutorials. There are numerous additional articles in this Asterisk HOW-TO series to keep you busy. You can read all of them by clicking here and scrolling down the page. We recommend reading at least the first four or five articles from the bottom up so that the learning curve is less painful. Then you can skip around to your heart's content.

Say It Ain't So. Sony reportedly is taking the low road and employing a rootkit to hide copy-protection mechanisms on its latest CDs and your PC, just what every virus creator on the planet has yearned for. Before you buy anything else from Sony/BMG, read this. Update: A recent article indicates that Sony's rootkit may, in fact, "phone home" to Sony with details of your music listening habits as well as your IP address. And what does Sony have to say about the controversy? They apparently don't think most folks are smart enough to know what a rootkit is. And what does Sony think you should be able to do with your newly purchased CD? Read this eye-opener before you hand over any more money to Sony. Let the lawsuits and prosecutions begin.

Internet Telephony Shootout II: Finding the Best International VoIP Provider for Asterisk

This is the second in our two-part roundup of the best unlimited calling plans for Asterisk®. You can read the first installment here. The number of options for Asterisk residential users wanting an unlimited international calling plan has fluctuated between zero and one depending upon how brave you were in dealing with BroadVoice's Terms of Service. Frankly, we've pretty much written off BroadVoice's so-called unlimited international calling plans for residential use because of the number of backbilling complaints logged on the Voxilla Forum.

Finally, there's not only some competition but also a ray of hope. Axvoice Inc. has recently announced two new unlimited residential calling plans with full bring-your-own-device support for Asterisk. An $18.99 plan provides unlimited calling within the U.S. and Canada. Spending $4 more buys you unlimited calling within the U.S., Canada, and all or parts of the following countries: Buenos Aires, Argentina; Australia; Chile; Denmark; France; Germany; Hong Kong; Ireland; Israel; Italy; Monterey and Mexico City, Mexico; Netherlands; Norway; Moscow and St. Petersburg, Russia; Singapore; South Korea; Spain; Sweden; Taiwan; United Kingdom; and Vatican City. As usual, mobile, premium, and special numbers are not included in the program. The fine print places a 4,000 minute usage cap on residential service before it is considered business use. This seems more than reasonable considering that such a number gives the residential user over two hours of free calls per day, every day of the year. Stated another way, the $22.99 international calling plan provides up to 4,000 minutes of calling per month to 24 countries for an average per minute cost that works out to just over a half cent a minute. Compared to the BroadVoice approach which leaves you guessing (at your financial peril) what the usage caps are for their various unlimited* calling plans, the Axvoice approach is a breath of fresh air. If you need to stretch your minutes and receive significant numbers of incoming calls, you can supplement your all-you-can-eat plan with a BYOD plan featuring unlimited, free incoming calls for $8.99 a month. Or you could simply add another all-you-can-eat plan for an additional 4,000 minutes. You can't beat the price, and all of Axvoice's plans include two free incoming DID numbers from a broad selection of area codes within the U.S. and Canada. Currently Axvoice is waiving the $9.99 setup fee for bring-your-own-device users. How do the calls sound? Ours sound great. Your mileage may vary. But you can try it for yourself with their 30-day money-back guarantee. So you really have nothing to lose by trying out their service. And, if you stay with Axvoice, all of their bring-your-own-Asterisk plans are month to month so there are no long term commitment issues.

The equally important question for Asterisk users is always the same. Does it work well with Asterisk? Again, the good news is that, once configured, Axvoice and Asterisk are a match made in heaven. In fact, Axvoice uses Asterisk at their end so you wouldn't expect anything less. Axvoice is a relatively new company, but you'll notice some marked differences from BroadVoice if you've endured BroadVoice support with their long waiting times and frequent disconnects while on hold. I think I was one of the first home users that wanted to set up Axvoice service with Asterisk so I can't say it was painless, but I can pretty much assure you that the process will be close to painless for you. We wrote down the answers! At least as this article goes to press, when you sign up on their site, you won't be greeted by much of any documentation pertaining to Asterisk configuration. All that's about to change if you keep reading here. Again, they're a new company, and we pretty much knew going in that it probably would be a bumpy ride. At least for the first three days, we weren't disappointed. The good news is that email inquiries always were returned with a helpful answer within an hour or so. And calls to their toll-free number were answered in less than a minute both during the business day and at night. You really couldn't ask for much more.

I think it would be fair to say that Axvoice's typical customer up to now has pretty much been like Vonage's, dumb as a brick about technology and looking for a good deal on an unlimited VoIP calling plan. So, when you call for customer service, the typical first response is to inquire about your router/firewall. And they fully expect you to answer by saying, "What's that?" Unlike Vonage, Axvoice fully supports Asterisk with an open SIP configuration. But it took some perseverance to get to the person who knew the answers. Some of the first-level customer service reps were having a difficult time both with English and trying to understand that we, too, had an Asterisk server ... at our home. "Really?" was a typical response. Once we got by all of that, the Asterisk configuration information was detailed and to the point. The other wrinkle we experienced had to do with their support for the G.729 codec. We only have one license which may have been the problem. Outgoing calls with G.729 worked fine, but incoming calls that first hit our AutoAttendant and then get transferred to a default extension lost the outgoing part of the audio. This may be because Asterisk treats the two voicepaths (incoming and the answering extension) as two separate channels requiring two, rather than one, G.729 license. When payday rolls around, we'll splurge for another $10 G.729 license from Digium®, and let you know the results. In the meantime, the default ulaw codec works great.


Configuring Asterisk Trunk for Axvoice. Assuming you decide to take the dare and sign up for a test run, what you're going to need to get Asterisk running with Axvoice is your account ID (not a phone number) and your password. If you've followed along in our previous Asterisk@Home tutorials, then the process to set up Axvoice will be familiar. Be sure UDP ports 5004-5082 and 10000-20000 are opened on your firewall and pointing to your Asterisk server. We'll create a trunk for Axvoice and then add Axvoice to our dialplan to take advantage of their calling plan. Using the Asterisk Management Portal, goto AMP->Setup->Trunks and Add a New SIP Trunk. You can leave the CallerID field blank since this is configured on Axvoice's web portal. For maximum channels, enter 2. For Outgoing Dial Rules, enter the following but be aware that this dialplan will allow international calling to many country codes that are NOT free under the Axvoice unlimited international calling plan. If this is a problem in your household, you'll need to make your dialplan much more country-code specific.

1+NXXNXXXXXX
1NXXNXXXXXX
011X.

For Outgoing Settings, name your trunk axvoice and then enter the following Peer Details substituting your username (3 entries) and password (1 entry) where appropriate:

allow=ulaw
authname=yourusername
canreinvite=no
context=from-sip-external
defaultip=sip.axvoice.com
disallow=all
dtmfmode=rfc2833
fromdomain=sip.axvoice.com
fromuser=yourusername
host=sip.axvoice.com
insecure=very
nat=yes
secret=yourpassword
type=friend
user=phone
username=yourusername

Leave the Incoming Context and Details blank. Enter your registration string as follows using your actual username and password. Then save the trunk and click the red bar to reload Asterisk.

yourusername:yourpassword@sip.axvoice.com

You will recall from our previous article on the subject that the [from-sip-external] context passes incoming calls to our Stealth AutoAttendant for processing. So Axvoice incoming calls will be handled in the same way as incoming calls from your other PSTN and VoIP trunks.

Adjusting Outgoing Dialplans for Axvoice. To adjust your dialplans to take maximum advantage of Axvoice, choose AMP->Setup->Outbound Routing. Then for your Local, InState, TollFree, and US dialplans, edit each of them and Add the SIP/axvoice trunk. Then use the arrow keys to move Axvoice to the top of each list. You'll also want to add a new International route with the following Dial Pattern: 011X. which designates all calls beginning with 011 and at least two more digits as international calls. Now choose SIP/axvoice as your one and only trunk for international calls. If you want a fallback trunk, Voxee would be our recommendation. They have incredibly low per minute rates. Now save your trunk settings and leave the international dialplan at the bottom of your list of Dialplan Routes.

Making a Test Call Using Axvoice. To be sure everything is working swimmingly, start up Asterisk in interactive mode using the Command Line Interface (CLI) so that you can actually watch what's happening when calls are placed and received. This works best if you connect to your Asterisk server through SSH from a Mac or PC. SSH comes with every Mac and the syntax is simple: ssh root@AsteriskIPaddress. If you're still chained to Microsoft, download Putty from the Mother Country, and you can do the same thing using a Windows machine. Once you're logged in as root, issue the following command: asterisk -r. Quit ends your Asterisk CLI session, and exit logs you out of your SSH session. Now issue the command: set verbose 10 to get maximum information. Then place a U.S. or international call and watch what happens. You should see something similar to the following which shows that the call was placed using the new axvoice trunk:

-- Called axvoice/18435551212
-- SIP/axvoice-2cbf is ringing

Asterisk: The Future of Telephony. O'Reilly Publishing finally released a great book on Asterisk last week. The book is available directly from the publisher or from Amazon. In addition, O'Reilly is providing the PDF version at no cost under a Creative Commons License. It's a carefully written book and an easy read for beginners as well as those with lots of Asterisk miles under the belt. It does not cover Asterisk@Home. And what more can we say about O'Reilly Publishing. O'Reilly is simply one terrific company that just keeps getting better! Some other Asterisk books are now available as well. You can read all about them here. And at least one Asterisk@Home book is currently under development ... not from us. We don't do books. You can always tell when a new technology is really taking off by watching for book publications. For those that have been following these tutorials, I think you understand why Asterisk is finally earning its rightful place in the limelight.

Other Tutorials. There are numerous additional articles in this Asterisk HOW-TO series to keep you busy. You can read all of them by clicking here and scrolling down the page. We recommend reading at least the first four or five articles from the bottom up so that the learning curve is less painful. Disclaimer: As we have mentioned previously, we typically sign up for referral credits when we try out a new VoIP service. If our referral credit links give you heartburn, don't use them. We do it to help defer costs of this column. It doesn't influence our views of the providers as you probably can tell from our discussions of BroadVoice. They too have a referral credit program, and we still don't like their current terms of service. Fortunately, thanks to Axvoice, international callers finally have another viable unlimited calling plan option.

Coming Thursday: AsteriDex -- The Poor Man's Rolodex. We're excited about our latest free software offering and think you will be, too. AsteriDex is a web-based application that lets you store phone numbers of all your friends and business associates in a simple-to-use MySQL database. But, it's much more with Asterisk! Just call up the application in your favorite web browser from anywhere and click on the contact you want to call. AsteriDex will first call you at the number you've designated for this contact, and then AsteriDex connects you to your contact through an outbound call made using your Asterisk server. For those lucky enough to have GrandStream's GXP-2000 IP phone with AutoAnswer, you can even configure AsteriDex to automatically activate the speakerphone and then place the call to the contact you've selected. In short, it works exactly like Microsoft's TAPI software without the configuration nightmare or your favorite (required) Micro$oft bloatware. Installation and configuration for your Asterisk@Home system is a snap and takes less than 10 minutes. It also works with vanilla Asterisk running the Asterisk Management Panel (AMP) software. Someone is probably saying, "Can't you do the same thing with CRM?" Well, yes and no. If you need full-blown contact management, then sure you can. Just be sure to save an extension for the account you are using to log in using the format sip/204. CRM will dial out using your default Asterisk outbound dialing rules, and it works great. But be prepared to spend several months getting all your contact information entered. AsteriDex is quick to implement and simple to use because it only does one thing: places calls for you using a web interface to all your favorite callees. The software is distributed without charge pursuant to the Creative Commons License.

Phone Home Revisited: Getting Remote Dialtone With Asterisk — Three Great Solutions

Phone HomeOne of the really terrific features of Asterisk® is it’s ability using DISA (Direct Inward System Access) to provide dial tone to an incoming caller. This allows a caller to Phone Home and place outgoing calls through a remote Asterisk server to take advantage of all those VoIP cost savings we’ve been discussing ad nauseum. You obviously need to be thinking about security before you implement DISA but, properly secured, DISA is one of the most powerful functions of your Asterisk PBX so why not use it to your advantage. But there are some wrinkles. Suppose you’re traveling in a foreign country that charges a $14 minimum for any completed call to the U.S. regardless of duration. Or you may just be at a neighbor’s house and want to make a quick call on your nickel to check on Aunt Betty in Paris. Or you may be on a Nextel free incoming call plan and don’t want to burn up your cellphone minutes placing outgoing calls directly with your cellphone.

Several weeks ago, we provided a quick and dirty HOW-TO on activating a DISA callback using a web browser and entering a specific command to your Asterisk@Home’s web server. But there may be folks that don’t want the security risks associated with supporting a web server. So today we want to revisit our original Phone Home column and give you three different ways to implement DISA. The three methods are the following: (1) the AutoAttendant, (2) the CallMe Web Interface, and (3) the One Ringy-Dingy. These obviously can be mixed and matched to meet your own specific requirements.

AutoAttendant DISA. The simplest DISA implementation is to add an option to your AutoAttendant. With this option, you phone home, pay the costs of the call, and while still connected make another call through your Asterisk server by picking the DISA selection when your AutoAttendant plays. You’ll be prompted for a password and, after entering it correctly, Asterisk will provide dialtone for your use. The drawback of this option is obviously the cost, if any, of the call to your home base. If that’s not a problem, then this is a great solution. And it’s very easy to implement. Take a look at the [from-external-custom] code in our Securing Your Asterisk@Home PBX article for all the details. But basically you only need to add a couple of lines to your AutoAttendant to support DISA. Choose the number that people will press to activate DISA and pick a very secure password, and you’re all set. Assuming the number to press is 4 and your chosen password was 1234588, here’s how to set up the AutoAttendant code to implement DISA. It doesn’t get much easier than this.

exten => 4,1,Authenticate(1234588)
exten => 4,2,Background(pls-wait-connect-call)
exten => 4,3,DISA(no-password|from-internal)

CallMe Web Interface. We’ve put together a little web application (actually a PHP script) so that, using a web browser on the road, you can tell your Asterisk server to call you and provide dialtone to any number you specify. The only prerequisite here is that we don’t want to sell the farm, i.e. provide free dial tone service and unlimited international calling for all the world’s hackers and crackers. We also don’t want to have to go through a bunch of authentication steps to access the web site and put the call in motion. So here’s the design. We have a PHP script which you can download here. It needs to be renamed to callme.php. Then copy it into the /var/www/html directory on your Asterisk server. You’ll also need to tell your firewall/router to route HTTP or port 80 traffic to the internal IP address of your Asterisk server. This is usually done under the Services or Rules menus on most routers. You’ll want to specify that all port 80 traffic be allowed through the firewall all of the time. Be sure you’ve changed ALL of your Asterisk passwords before you do this!

To use this script from the Internet, you’ll probably want to have to have a more permanent fully-qualified domain name associated with your Asterisk server. We explained here how to do this using dyndns.org. If you use a SIP provider with your Asterisk server, the syntax is as follows: http://asterisk.dyndns.org/callme.php?number=sip/bv/4045551212 where asterisk.dyndns.org is the fully-qualified domain name for your Asterisk server and 4045551212 is the area code and number where you wish to accept a call with dialtone, and bv is the outgoing trunk name of your SIP provider. If you use an IAX provider with your Asterisk server, the syntax is as follows: http://asterisk.dyndns.org/callme.php?number=iax2/goiax/14045551212 where asterisk.dyndns.org is the fully-qualified domain name for your Asterisk server and 14045551212 is the all-important 1 followed by the area code and number where you wish to accept a call with dialtone, and goiax is the outgoing trunk name of your free IAX provider. Nothing else needs to be changed. To dial a local extension, use this syntax: http://asterisk.dyndns.org/callme.php?number=sip/204 where asterisk.dyndns.org is the fully-qualified domain name for your Asterisk server and 204 is the local number to ring. Beginning on the first ring, Asterisk will start prompting for a password. It doesn’t care whether the call is answered or not, and it times out after 10 seconds. After three unsuccessful password attempts (each timeout counts as 1), Asterisk hangs up. Stated another way, you have about 30 seconds to enter your password after the phone first rings. Then Asterisk disconnects the call. To enter your password, key in the touchtone numbers which match the numerical password code you specified in your [callout] context (see below). Then press the pound (#) key. Note that a web page will not display at this web address unless you enter the portion of the address following the question mark. Nor will a call be placed unless the sip/bv/ syntax precedes a phone number. We did this for security reasons.


Before the above script will work, you also need to add the following context to the bottom of the extensions_custom.conf configuration file discussed above. Make sure you change the password 24681234 to something very secure. After all, it’s your phone bill! Once you make this change, it won’t take effect until you restart Asterisk. The easiest way to do that is to access setup within AMP, click Incoming Calls, then click the Submit Changes button, then click on the red bar which appears. Count to 10 and your changes should be operational.

[callout]
exten => s,1,Authenticate(24681234)
exten => s,2,DISA(no-password|from-internal)

One Ringy-Dingy. As we mentioned at the beginning of this article, there may be times when you don’t have access to a web browser and the cost of completed outgoing calls is astronomical. Or you may just find it more convenient to place a quick call to your Asterisk server rather than firing up a web browser. For the One Ringy-Dingy option to work, you must place a call to your Asterisk server from a phone that can accept incoming calls directly (not most hotel rooms or pay phones), and you must call from a phone with a legitimate CallerID number. Ideally, for this option to work in an unattended way all the time, you’d want to have a separate Direct-Inward-Dial (DID) number dedicated to this task. Why? Because, once Asterisk detects one ring on this number, it will issue a Congestion tone (fast busy) and immediately build and then process a DISA script to call you back. That obviously isn’t a desirable response on your regular phone number. We still will configure DISA to prompt for a password when the return call is answered, but callers may be a little surprised if they call you at home, hear a fast busy, and then immediately get a return call from your home asking them for a password.

Here are the steps to get this set up. We’ll tweak our Asterisk@Home/AMP dial-in context to turn on support for tracking incoming calls by DID. Then, for security, we’ll build a separate context for this DID number to isolate it from our default AutoAttendant which manages the rest of our incoming calls. Once we have the DID context created, we’ll build a DID entry in AMP to support this incoming line. Next, we’ll drop in the code to actually process the incoming call and build and execute the scripts necessary to make the return call. There are several new and very important Asterisk features that we’ll be taking advantage of. First, we’ll be executing code based upon a ringing phone line as opposed to an answered call. Second, we’ll show you how to execute context code and scripts after a call ends. And finally, we’ll be setting a maximum call limit on the outgoing DISA calls just to provide some food for thought on how you can better harrass your teenagers. So let’s get started.

Tweaking the Dial-In Context. From our previous articles, you will recall that Asterisk@Home and other Asterisk systems using the Asterisk Management Portal (AMP), rely upon the [from-sip-external] context in extensions.conf to process incoming calls. Right now, we have that context pointed to our AutoAttendant context which we built in the extensions_custom.conf file. You can read all about how to build the AutoAttendant here. The AutoAttendant implementation effectively disabled support for AMP’s DID Routes, but it secured your Asterisk system by reducing the number of points of attack to one, i.e. every incoming call had to flow through our one AutoAttendant. For those just getting started with Asterisk, this was a good thing. But, now that you’re an expert, we need a little more flexibility because we want to set up a DID line just to handle requests for DISA services, and we don’t want incoming calls on that line going to our AutoAttendant. Why? Because, with a separate DISA DID, we can eliminate any costs in placing calls to the Asterisk server requesting remote dial tone. How? This DID will never be answered. All it will do is ring once or twice before handing out a Congestion tone, and that activity will be sufficient to capture the incoming call’s CallerID and then set in motion the DISA return call process … hence the name One Ringy-Dingy. Won’t the telemarketers be thrilled! Just think of this DID as a toll-free number without having to pay for a toll-free number. To turn on support for AMP’s DID Route management, just add the following line to your [from-sip-external] context, and be sure you add it immediately below the [from-sip-external] label. See how easy this is when there’s some documentation (HINT!).

include => ext-did

Configuring an AMP DID Route. Now that we’ve activated DID Route support for Asterisk, let’s actually build a DID Route to show you how it’s done. This presupposes that you’ve ordered an additional DID from one of your providers and that you already have a trunk for that provider set up. When you order the additional DID, make sure that you specify that you do not want voicemail activated on this DID. Or, if you have control of the voicemail setup for this DID, turn it off. The reason is that, when incoming calls to this number get a congestion tone from Asterisk, that will activate the voicemail option with most providers. That, in turn, defeats our purpose of not answering calls ringing on this DID line to save money.

To create the DISA DID route, use a web browser to access the Asterisk Management Portal. Then choose AMP->Setup->DID Routes. Plug in the DID phone number you wish to assign to DISA duty. For the Destination, click on the Custom App button, and then enter the following: custom-teliax-in,8435551212,1 substituting your actual DID number. Click the Submit button and then the red bar to reset Asterisk. Note that AMP does no error checking for this custom context other than looking for the word "custom." Remember, we haven’t even built this context yet! But let’s do it now.

DISA Custom Contexts. For our One Ringy Dingy example, we’re going to use two different providers. The DID line is rented from Teliax.com. That’s where you call to trigger a callback. But Teliax is just too expensive for actual outgoing or incoming calls so we’re using two TelaSIP trunks (with permission): one to return the call to the original caller (that’s you or me) and one to place our outgoing DISA call (to the callee). If you happen to use TelaSIP, remember that you don’t need two separate accounts for the outbound calls since TelaSIP gives you two voice paths with your single line account.

There are three separate contexts we need to create at the bottom of extensions_custom.conf file to make all of this work. Keep in mind that there are three steps in the One Ringy-Dingy process: (1) you place a call to your DID number, and your Asterisk server detects the incoming call; (2) your Asterisk server calls you back, and you’re given dialtone after successfully entering your DISA password; and (3) your Asterisk server lets you to place an outgoing DISA call for a specified length of time to anywhere permitted in this context’s custom DISA dialplan. Here are the three contexts to support the three functions: (1) [custom-teliax-in] listens to the DID line for an incoming call and then sets up and executes the code setting the return call in motion; (2) [custom-telasip-callout] actually manages the return call once someone answers and authenticates the user for DISA service; and (3) [custom-telasip] sets the dialplan and timeout options for the call and then actually connects and times the call if the caller satisfies the dialplan rules. If you’re a little confused at this point, an example may help. Skip down to the Free Samples section below and actually try a test call to see how all this works. Then come back, and we’ll finish building it for your own Asterisk system.

Incoming Call Context. So a user first calls your DID number to initiate a DISA callback. Let’s start with the code that handles the incoming call on your DID line:

[custom-teliax-in]
exten => 8436541010,1,NoOp(Incoming call from Teliax #8436541010)
exten => 8436541010,2,Congestion
exten => 8436541010,3,Hangup
exten => h,1,SetCIDNum(${CALLERIDNUM:2})
exten => h,2,System(echo channel: SIP/telasip-gw/${CALLERIDNUM} > /tmp/${CALLERIDNUM})
exten => h,3,System(echo context: custom-telasip-callout >> /tmp/${CALLERIDNUM})
exten => h,4,System(echo extension: ${CALLERIDNUM} >> /tmp/${CALLERIDNUM})
exten => h,5,System(echo priority: 1 >> /tmp/${CALLERIDNUM})
exten => h,6,System(echo callerid: 2025560000 >> /tmp/${CALLERIDNUM}) ; Your CallerID for your TelaSIP account goes here
exten => h,7,System(echo sleep 30 > /tmp/${CALLERIDNUM}.2)
exten => h,8,System(echo cp /tmp/${CALLERIDNUM} /var/spool/asterisk/outgoing >> /tmp/${CALLERIDNUM}.2)
exten => h,9,System(chmod 775 /tmp/${CALLERIDNUM}.2)
exten => h,10,System(/tmp/${CALLERIDNUM}.2)
exten => h,11,Hangup()

Let’s walk through each line of the script so that you’ll know what needs to be changed on your own system if you use this. The first three lines get processed every time someone calls your dedicated DISA DID number. Adjust the numbers in each line to match your DISA line’s 10-digit CallerID number. Line 1 just outputs a message to the console indicating that there’s an incoming call on this line. Line 2 sends the Congestion tone back to the incoming caller. Line 3 is just a safety net to be sure the call is hung up as far as Asterisk is concerned. The next 11 lines beginning with exten=>h tell Asterisk what to do when it detects that the caller has hung up on the call. This code gets processed after the caller hangs up or after Asterisk processes the Hangup command in the third line.

Line h,1 is very important. Different providers relay CallerID numbers in different ways. Teliax sends a U.S. number as +14041234567. Many providers (including BroadVoice and TelaSIP) just send the ten-digit number for incoming U.S. calls. You need to know this because we’ll need to format the CallerID number properly to match what your outgoing provider expects to see when you process the return call in step 2. So how do you know what the CALLERIDNUM format is? Run asterisk -r from a command window and watch the information about an incoming call on the DID line you plan to use. If the format is a 10-digit number, then change SetCIDNum(${CALLERIDNUM:2}) to SetCIDNum(${CALLERIDNUM:0}) which means "use every digit as received." If the number is in the format 1+8901234567 then leave the expression the way it is. It basically says strip off the first two digits and store the rest as the CallerID number.

Line h,2 is where you identify which of your VoIP providers will be used to place the return call in step 2. If you’re using TelaSIP (as we are here), then just make sure the outbound trunk name matches your entry for this provider under AMP->Setup->Trunks. If you’re using an IAX provider instead of a SIP provider, change SIP to IAX2 as well. Finally, be sure what is now a 10-digit CallerID number is formatted properly for the return call through your dialback provider. TelaSIP wants a 10-digit number. GoIAX, for example, expects to receive a 1 and then the area code and number. For GoIAX, just insert a 1 before the CallerID number.

Line h,3 identifies the context which will actually place the return call. Line h,6 is where you specify the CallerID number of your Asterisk trunk that will be placing the return call. Teliax, for example, lets you spoof the CallerID for your calls so this is where you would enter the main number of the White House (if that’s your thing): 2024561414. Finally, in line h,7 you can set how much of a delay will be imposed before your Asterisk system places the return call. It’s set to 30, but you can change it to meet your requirements. The rest of this code should work as is.


Callback Context. Now we’re ready for Asterisk to place the return call. The previous code actually sets the call in motion with a 30 second delay and then a call to the CallerID number specified using the [custom-telasip-callout] context. But here’s the code that actually manages the callback. It also prompts for the DISA password once someone answers. Line s,3 is where you set the DISA password. Make it secure! Remember: IT’S YOUR PHONE BILL!

[custom-telasip-callout]
exten => s,1,Background(silence/2)
exten => s,2,Background(asterisk-friend)
exten => s,3,Authenticate(6373)
exten => s,4,Background(pls-wait-connect-call)
exten => s,5,DISA(no-password|custom-telasip)

When someone answers the return phone call, Asterisk counts to 2 and then says, "Asterisk is your friend. Please enter your password and press the pound key." That’s the person’s clue to enter their DISA password. Three guesses and Asterisk hangs up. If the password is successfully entered, Asterisk provides dialtone and passes the call to the [custom-telasip] context in s,5.

DISA Outbound Call Context. Once dialtone is provided, the user can enter whatever digits are permitted in the [custom-telasip] context’s dialplan. Here’s ours:

[custom-telasip]
exten => _1NXXNXXXXXX,1,AbsoluteTimeout(600)
exten => _1NXXNXXXXXX,2,Macro(dialout-trunk,8,${EXTEN:1},)
exten => _1NXXNXXXXXX,3,Macro(outisbusy) ; No available circuits
exten => T,1,Playback(thank-you-for-calling)
exten => T,2,Playback(goodbye)
exten => T,3,Hangup

Lines 1, 2, and 3 specify that the user has one and only one dialing option: dial 1 and then a 3-digit U.S. area code and then a 7-digit U.S. phone number. Line 1 is where you set the maximum duration for the call in seconds (600=10 minutes). Line 2 is where you really have to be careful. It has three gotcha’s. First, you need to identify which trunk will be used to place the DISA call. If your provider only offers one dial path per circuit, then this trunk cannot be the same one as what’s specified in custom-telasip-in,h,2 above or you’ll get an "all circuits are busy" message. In short, you need one outbound trunk for the callback and another outbound trunk to place the actual DISA call from dialtone. If you use TelaSIP’s residential plan, then you can use the same trunk for both. Second, you need to know the number of the dialout trunk to be used for the DISA call. AMP numbers all of your outbound trunks. If you look in the [globals] context at the top of the extensions_additional.conf file, you’ll see all of your outbound trunks labeled as OUT_1, OUT_2, etc. Find the number of the one that matches the name of the outbound trunk you want to use for your DISA call. Replace the "8″ in line 2 of [custom-telasip] with the appropriate number you wrote down. Don’t use OUT_8, just 8. Third, you’ve got to get the DISA number dialed by the user properly formatted for the provider that will be handling the call. In our case, we accepted only numbers beginning with 1 plus a U.S. area code plus a 7-digit number, but TelaSIP doesn’t want the 1 so we strip it off. If, however, your provider (such as GoIAX) expects a 10-digit number with a leading 1, then you’d adjust line 2 above to look like this: exten => _1NXXNXXXXXX,2,Macro(dialout-trunk,8,${EXTEN},). This tells Asterisk not to strip off the first digit before sending the rest to dialout-trunk 8. The extension entries beginning with an upper case T tell Asterisk what to do when the maximum duration of a call expires.

That about does it. To complete your work, save the three new contexts to extensions_custom.conf and then restart Asterisk.

Making a Test Call. To be sure everything is working as it should, start up Asterisk in interactive mode using the Command Line Interface (CLI) so that you can actually watch what’s happening when calls are placed and received. This works best if you connect to your Asterisk server through SSH from a Mac or PC. SSH comes with every Mac and the syntax is simple: ssh root@AsteriskIPaddress. If you’re still chained to Microsoft, download Putty from the Mother Country, and you can do the same thing using a Windows machine. Once you’re logged in as root, issue the following command: asterisk -r. Quit ends your Asterisk CLI session, and exit logs you out of your SSH session. Now issue the command: set verbose 10 to get maximum information. Then place a call to your DISA DID number from your cellphone and watch what happens. You should see the call being processed without being answered. Asterisk will then issue a Congested tone and disconnect. Your CLI display will remain quiet for 20 seconds, and then the return call will be placed. When you answer the call, you’ll be prompted for your password. Enter it, wait for dial tone, dial a number with 1, then area code, then 7-digit number and watch what happens. If the call fails, exit from CLI by typing Quit. Change to the /tmp directory: cd /tmp. Do a directory listing in reverse date order: ls -all -t -r. At the bottom of the list should be two files with the area code and number of your cellphone. One will have a .2 extension. Display the contents of the file without the extension: cat 6781234567 using your cellphone number. The contents should look something like this. If not, check your typing in the contexts we added and try again. Keep in mind that editing either of these two files is pointless. They both get built on the fly in the h section of the [custom-teliax-in] context depending upon the CallerID of the caller. Linux will automatically handle deletion of files from the /tmp directory in due course.

[root@asterisk1 tmp]# cat 6781234567
channel: SIP/telasip-gw/16781234567
context: custom-telasip-callout
extension: 6781234567
priority: 1
callerid: 2025560000

And, yes, we know the extension specified does not match the extension (s) actually entered in the [custom-telasip-callout] context. But, fear not, your call will fall back to the s extension when Asterisk can’t find an entry matching your cell phone number. Why did we do this? Well, you may want to have Asterisk do something special when it knows it’s you calling from your cellphone or one of your kids calling from your house at the lake. For example, you might want to provide a wide open dialplan for yourself with a different password as well. Remember, people can spoof your CallerID number so make the password VERY SECURE! Here’s how it would look. Substitute your own cellphone number and a new password. Once you make the changes, restart Asterisk and then place another call from your cellphone to your DISA DID and try entering a local extension or a foreign phone number if your regular dialplan supports it. Enjoy!

[custom-telasip-callout]
exten => 6781234567,1,Background(silence/2)
exten => 6781234567,2,Background(asterisk-friend)
exten => 6781234567,3,Authenticate(63738488537)
exten => 6781234567,4,Background(pls-wait-connect-call)
exten => 6781234567,5,DISA(no-password|from-internal)

exten => s,1,Background(silence/2)
exten => s,2,Background(asterisk-friend)
exten => s,3,Authenticate(6373)
exten => s,4,Background(pls-wait-connect-call)
exten => s,5,DISA(no-password|custom-telasip)

Free Samples. Everybody loves free samples so here’s one for you. You may remember Gene Willingham and the good folks at TelaSIP, the winner and least expensive provider in our unlimited U.S. long distance calling shootout. In a moment of weakness, TelaSIP’s agreed to let you try out our One Ringy-Dingy service (known affectionately around our house as the One Rinky-Dink Service because of the amount of time we’ve wasted on this). Anyway, it uses our Asterisk server and TelaSIP’s long distance bandwidth. Calls are limited to 10 minutes after which the callee will hear "Goodbye" followed by a click. You’ll get two beeps followed by a fast busy. In other words, time’s up! Here’s how to use this free service. Call from a phone in the U.S. with CallerID. Call the number shown on the map (inset) which is one of our DIDs in Charleston, South Carolina. The call will never be answered so you won’t be billed for the long distance call. Within 10 seconds, you should hear a fast busy. Just hang up, and our Asterisk server will call you back within 30 seconds. Listen carefully! You’ll be provided a random password for your call, and then you’ll be prompted to key it in. With your phone keypad, just do that and press the pound key (#). If you get a message that it’s incorrect, just try again (HINT: I told you to listen carefully). We used to have a fixed password, but the war-dialers were abusing the system so now it’s random. Back to the drawing boards, boys! Once you successfully enter the password, you’ll then get a DISA dial tone. Dial 1 and then the area code and phone number of someone you love (in the United States only). This is an excellent way for you to check out the voice quality of TelaSIP calls without spending a dime. Just don’t abuse the offer or this paragraph may magically disappear … as will the free calls. For those that don’t know us, we don’t record your calls, and we don’t store the number of the person you’re calling although the Asterisk logs probably have it for a while anyway. For security purposes, we do log your CallerID and the time of your call just in case you do something you shouldn’t be doing and the FBI traces the call back to us. If any of the above offends you, exercise your constitutional right to not use this free service. And a final reminder: none of this works if you don’t have CallerID enabled when you call. How would we know where to call you back? You won’t believe how many calls we receive with a CallerID of Asterisk. That obviously won’t work either.

Homework. There’s really a fourth DISA option. Under this scenario, you would call your home number, have the AutoAttendant answer, and then press 4 for DISA. After providing your password, Asterisk would hang up and call you back with DISA dial tone using the same type scripts we implemented in One Ringy Dingy above. The advantage of this approach is you don’t need a separate DID line to support DISA. The disadvantage is you have to pay for a one minute phone call to your home number each time you want remote dial tone. But it would save the expense of lengthy calls to your home just to use your outbound trunks. We’ll leave it to you to figure this one out. It shouldn’t take you long now that you understand how all the pieces fit together.


Some Recent Nerd Vittles Articles of Interest…

Internet Telephony Shootout: Finding the Best VoIP Provider for the Asterisk PBX

If you’re one of the 75,000+ Broadband Reports VoIP Forum subscribers who took advantage of the Staples/Vonage million dollar giveaway of easily unlocked Linksys PAP2 terminal adapters this past week and now you’d like to do more with VoIP than just make phone calls, welcome! For the rest of us including those that have been following our Asterisk articles these past few months, you already know that the hardest part of using Asterisk@Home or any other flavor Asterisk PBX is finding reliable, cost-effective VoIP providers that support home users of Asterisk. For business users, the prospects are even more bleak! With pay-as-you-go service, most providers don’t care what you connect with including Asterisk, and our experience suggests that Voxee.com (1¢ – 2¢ for most of the world with six second billing increments for U.S. calls) remains the best and most economical alternative, but it’s for outgoing calls only. And, yes, we love GoIAX.com with their free outbound calls within the U.S., and we love IPkall and Stanaphone for free incoming calls as long as you don’t mind a Washington state or New York City phone number. But, if there is one thing you can count on in the VoIP world, it’s this: free calling in or out probably won’t last forever. You do the math! Footnote: Matthew Simpson, who started the GoIAX service, promises us he’ll keep it going "forever" provided the cost of stamping out abusers doesn’t start outweighing the benefits of keeping the free service operational. We obviously wish him all the luck in the world and hereby donate this terrific, new (and free) firewall to assist in his efforts. He’s probably going to need it.

More problematic is finding a provider in the United States that supports Asterisk with an unlimited residential calling plan and a local phone number at a decent price. While BroadVoice advertises incredibly cheap international calling plans as unlimited with local phone numbers in most U.S. area codes, their fine print and the number of complaints of backbilling and other financial shenanigans posted on the Voxilla forum suggest that you’d better be extremely careful if you elect to use one of BroadVoice’s so-called Unlimited* Calling Plans with much of any call volume. As your Mama used to say, "If something sounds too good to be true, it probably is." For our review of international calling plans, go here. Last week we reviewed Yahoo’s dialpad service, but the voice quality of the calls just wasn’t satisfactory at least for our purposes, and there was no support for incoming calls with a local phone number. We personally liked Teliax, but they charged 2¢ a minute (rounded to whole minutes) for outgoing and incoming calls plus $5 a month for a local number (DID). And, when something comes unglued at their end, good luck getting it fixed. We had a DID that worked reliably and then all of a sudden you got a fast busy when folks called the number. In short, the calls never made it to our Asterisk server at all, and we showed them our logs to prove it. Unfortunately, explaining the situation to the Teliax support folks was a bit like talking to a toddler. They heard the words, but … Suffice it to say, the line remained dead in the water for almost a week before magically coming back to life. So we’re kissing Teliax goodbye for breaking Telecom Rule #1: When someone calls, our phone needs to ring! Then we looked at VoicePulse Connect with free incoming calls and a local number of your choice, but it’s $11 a month, and you then have to pay 4¢ a minute for outgoing U.S. calls. Yes, VoicePulse has all-you-can-eat plans, but they won’t support Asterisk. They will let you purchase a second line for Asterisk and pay 4¢ a minute for U.S. calls. We can do about as well with a WalMart phone card. So where does that leave us? Exhausted but persevering…

Just when we thought the Asterisk landscape was looking pretty bleak in the U.S. all-you-can-eat department, we stumbled upon a VoIP provider that loves and actually uses Asterisk, has state-of-the-art servers and a network backbone to match, demonstrates incredible depth of experience in the VoIP market, doesn’t play mind games with unconscionable terms of service (i.e. unlimited long distance calling means unlimited long distance calling), and has dirt cheap all-you-can-eat U.S. residential calling plans with local phone numbers for incoming calls. How much? $14.95 a month with no hidden "recovery" fees. For business users, you won’t find a better collection of business offerings on the planet. There are cradle-to-grave plans, or you can do-it-yourself for $40 per trunk with $1 DID’s and unlimited U.S. local and long distance calling. Even with its $100 monthly minimum, the latter is a great deal on PSTN origination and termination service for almost any size business. If you’re a small business and these plans don’t quite meet your needs, send them an email, and I’m pretty sure they’ll work out some cost-effective arrangement that meets your needs. Having tried dozens of VoIP providers over the past few months, suffice it to say, we’ve learned to spot the duds, the con artists, and the crappy providers just about as quickly as you can sign up for service. What you won’t get with this provider is a splashy web site with flashing signs promising you the moon … only to learn (later) that your free trip was just one way. Nor will there be a lot of hand-holding support although we received a return support call from the founder of the company in less than 30 minutes, and he didn’t know us from Adam. If you want handholding, then Vonage with a locked PAP2 phone adapter and no Asterisk server may be your best ticket to experience VoIP. Or here’s a cheaper alternative. BellSouth will sell you residential CallerID in Atlanta for only $8 a month … no phone line, no free calls to anywhere, no dial tone, no phone, just CallerID. And they wonder why their customers are leaving in droves.

So, where were we? If you’re comfortable with Asterisk and just looking for rock-solid reliable calls and an unlimited U.S. calling plan where you can actually hear the person at the other end of the line, then we’ve found a provider for you at a very reasonable price. Have we dragged this out long enough? The winner is VoipXpress aka TelaSIP. Congratulations to Jacob Brassington, who correctly guessed the winner in a posted comment following last week’s column. We didn’t publish the wrong guesses to protect the innocent. Our recommendation is that you try the $14.95 VoipXpress Premium plan for yourself. And, yes, the company founder, Gene Willingham, will give you your money back if you’re not satisfied. Or, if you just don’t trust anybody without a little personal testing, sign up for the VoipXpress Basic plan which is free with 4¢ per minute pay-as-you-go domestic calls.

Full Disclosure & Freebies. Like most other VoIP providers, VoipXpress helps a bit to defray the costs of the bandwidth for this blog if you sign up using the link we’ve provided. Sorry, but we’re addicted to referral credits, and you, too, can get them once you sign up for service. Anyway, it costs you nothing and helps us a little. But, if the referral stuff bothers you, just delete the PARTNER portion of the link to VoipXpress once you arrive on their web site. We like their service with or without referral credits. You will get a freebie, however, if you use our link. During October, VoipXpress will give you a second DID number in your choice of area code at no additional charge. Their DID’s are normally $1.95 a month, the best residential DID bargain around for those that need or want numbers in multiple places. Just mention Nerd Vittles when you sign up during October to get your second DID in almost any area code at no cost.


Configuring Asterisk@Home for VoipXpress. Now let’s get VoipXpress working with your Asterisk@Home system. The VoipXpress servers are actually maintained by their parent company, TelaSIP. We need to add a simple context to process incoming calls and then add a new trunk in our Asterisk@Home system. Finally we’ll reconfigure the outbound dialing routes to take advantage of the VoipXpress unlimited calling plan. Here’s how.

Point your web browser to your Asterisk@Home server’s IP address and choose AMP->Maintenance->Config Edit and choose extensions_custom.conf. We’re assuming you heeded our advice in our Securing Asterisk column and have already added a [from-external-custom] context to your extensions_custom file. If not, do that first! Now scroll to the bottom of the file and add the following new context substituting your Telasip assigned phone number for 4561234567. If you received two DIDs from TelaSIP, add three additional exten lines with your second number. Then click the Update button to save your changes.

[telasip-in]
exten => 4561234567,1,NoOp(Incoming call from TelaSIP #4561234567)
exten => 4561234567,2,Goto(from-external-custom,s,1)
exten => 4561234567,3,Hangup

Now let’s add a trunk for TelaSIP. Choose AMP->Setup->Trunks. Then click Add SIP Trunk. Why SIP and not IAX? The simple answer is there’s less call overhead between you and the provider. With SIP, only signalling information is passed to your provider while the data for the call itself (i.e. the heavy lifting) is strictly between you and the person you’re calling. Now where were we? For your Outbound Caller ID, fill in the local phone number provided by Telasip. For Maximum Channels, enter 2. That means that, unlike most providers of unlimited service, your account can handle two simultaneous calls in or out of your house with TelaSIP. For Dial Rules, enter the following substituting your local area code for 404:

1|NXXNXXXXXX
NXXNXXXXXX
404+NXXXXXX

In the Outgoing Settings section, name your trunk telasip-gw and then enter the following PEER details using your TelaSIP-assigned username and password:

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

Leave the Incoming Settings User Context and User Details blank. For your Registration string, enter the following: yourusername:yourpassword@gw3.telasip.com using your actual username and password assigned by TelaSIP. Click Submit Changes and then the red bar to restart Asterisk.

Adjusting Your Dialplans To Support VoipXpress/TelaSIP. If you’re using the Outbound Dialplans that we’ve built in the last few episodes, then it’s a simple matter to move SIP/telasip-gw up this list of priorities. Using AMP->Setup, click the Outbound Routing tab and then select each of the following routes: Local, Tollfree, and US. For each route, add a new Trunk Sequence by clicking the Add button and choosing SIP/telasip-gw. Then move it to the top of your Trunk Sequence list for each route to make it your first outbound dialing priority. Save your changes and restart Asterisk.

Making a Test Call Using TelaSIP. To be sure everything is working swimmingly, start up Asterisk in interactive mode using the Command Line Interface (CLI) so that you can actually watch what’s happening when calls are placed and received. This works best if you connect to your Asterisk server through SSH from a Mac or PC. SSH comes with every Mac and the syntax is simple: ssh root@AsteriskIPaddress. If you’re still chained to Microsoft, download Putty from the Mother Country, and you can do the same thing using a Windows machine. Once you’re logged in as root, issue the following command: asterisk -r. Quit ends your Asterisk CLI session, and exit logs you out of your SSH session. Now issue the command: set verbose 10 to get maximum information. Then place a U.S. long distance call and watch what happens. You should see something similar to the following which shows that the call was placed using the new telasip-gw trunk:

-- Called telasip-gw/8435551212
-- SIP/telasip-gw-2cbf is ringing

Coming Attractions. Next week, we still have Digium®’s IAXy device to configure so that you can take a phone with you on the road and connect back to your Asterisk® server to make calls. And with the IAXy 2 (now shipping), you can even use MD5 encryption for your passwords to further protect your Asterisk system. We’ll show you how. Then we’ll turn our attention to faxing and show you how to reconfigure Asterisk@Home to perform double-duty as not only a versatile PBX but also a sophisticated fax machine. You won’t need any special fax detection hardware to make this work, and Asterisk@Home will automatically detect and capture incoming faxes using your VoIP line. No dedicated fax line required! Then Asterisk@Home will convert the faxes into PDF documents and forward them to any email address you choose. This works great with your SIP line from TelaSIP by the way and works rarely with VoIP service from BroadVoice … yet another reason to put on your traveling shoes.

For those on the West Coast, don’t forget that next week is the big Asterisk convention in Anaheim: Astricon 2005. It’s not too late to register. And all your favorite nerds will be there, except us unfortunately. It should be a great time to learn all about Asterisk and to hear and see what’s on the drawing boards.

Last but not least, we previously walked you through adding entries to extensions_custom.conf to blacklist your "favorite" callers. But, in a coming article, we’ll show you how to do the same thing automatically at the touch of a button on your phone. In addition, there are some easy tools to manually add and remove blacklisted callers from Asterisk’s internal database, and we’ll show you how to access them from your phone. As the holiday and election seasons approach, you’ll be glad you’ve mastered blacklisting. Have a great weekend.

Other Tutorials. There are numerous additional articles in this Asterisk HOW-TO series to keep you busy. You can read all of them by clicking here and scrolling down the page. We recommend reading at least the first four or five articles from the bottom up so that the learning curve is less painful. Finally, if you just want to brush up on your phone etiquette, don’t miss Lily Tomlin’s "This Is A Recording" (See inset of "Ernestine" pictured with a vintage tip-and-ring switchboard). There is no finer tutorial on the planet: "We don’t care. We don’t have to. We’re the phone company."