Friday, January 25, 2008

Whim Discovery: My Experience with Asterisk

It all started at Barnes and Noble in Downtown Denver. It was our anniversary weekend and one of the things we like to do downtown is hit the bookstore and enjoy quiet reading time. I was looking for a book on SELinux which I just couldn’t find in the Linux section. I came across another O’Reilly book called Asterisk: The Future of Telephony. I enjoyed a sunny afternoon reading through the book next to my wife. I only made it a few chapters in but I was hooked. I had just completed a MythTV project and was saving dough on TV already, why not the phone too! After we were done, I put the book back but the fire had already been started.

Over the next week I decided to pick it up. I went searching and low and behold found it as a downloadable PDF. I spent the next few days reading through it on my laptop and phone. Once I finished I decided it was time to give it a try. I started looking for hardware and the book had clearly recommended the Digium boards but didn’t mention anything else. I figured this out quickly and started reading reviews of other hardware for the SoHo option. I ran across an article talking about the Sipura SPA-3000 that was purchased from Voxilla that provided both an FSX and FSO (connection to the phone company and connection to a phone for those not into the lingo yet) for around the $80 mark. This was a good start so I searched and found the (now owned by) Linksys SPA-3102 on Voxilla on sale for about $75.
One week later I had the 3102 in my hot little hands, the thing that surprised me most was the size; it’s about the size of two decks of cards laid long-side to long-side. I headed down to the basement where all my hot and noisy computer toys are with the 3102 and a fistful of cables from the package. I plugged the Internet port into my gigabit switch and connected the phone-line to my Vonage Linksys TA and the phone side to my office phone. No sense in interrupting my POTS home-line just yet, my office phone could be the Ginny pig. Fired it all up and watched my logs for the MAC/DHCP IP address. Copied the MAC into my dhcpd.conf and gave it one of the statics out of my pool. Reboot and try to connect over browser, no-dice, no surprise, it’s a security risk. Like all Linksys devices, you have to connect to the LAN side port to get anything done at first. I ran up and grabbed my laptop and hooked it up to the LAN side. like the manual says, hmm, nothing, ipconfig, is the address is gave me, smart little thing, it must have seen that 192.168.0.* was the WAN side addressing and bumped a network so as not to conflict. Browsed to and there is the admin interface. My goal was to disable the router function and control it through the WAN port but after an hour of fighting with it, I figured out that I was being stupid and had no firewall rule allowing me to get from my firewall (where I was testing) to the LAN, I could get out and packets could get through but I was only allowing SSH from the firewall itself. Not running upstairs to see if it worked from my desktop got me. On the good side, I learned a little more about the 3120 while I was fighting my own stupidity like that you can do most of the web admin functions by picking up the phone and dialing **** where a pretty decent IVR menu lets you configure the system. One problem I did run into was setting a password somewhere that caused the IVR to prompt me for said password which couldn’t be determined… factory reset. I can see it from the network, time for dinner and pick it up tomorrow.

I could have probably setup the software earlier but I wanted to wait until I had the hardware in-hand. First step is to choose what flavor. There are so many choices; I found AsteriskNOW, Trixbox and regular Asterisk. Turns out the first two are full systems including the OS. I already have a server I recently built with Fedora 7 that’s running firewall, email, dhcp and dns for my network. I was previously running all of these services on an old Pentium II 300 with a whopping 128MB of RAM but after adding antispam and antivirus, it just wasn’t enough. I happen to have a few server class machines and ended up using a Sun V20z to replace the old box. This thing runs 2 x AMD Opteron 248 (64-bit) 2.2 GHz procs and has 4GB of RAM so it should be up to this task as well.
Now I have hardware, software and time. I am a huge fan of yum and rpm, it’s not that I’m too dumb to compile my own stuff; it’s just that I am lazy and hate tracking down dependencies. At first glance, I don’t see any RPM’s out there so I downloaded Asterisk 1.4.13 from the Asterisk web site, untared it and copied it to /usr/src. A less on the README is no big surprise, make clean, make, make install.

[root@irongate asterisk-1.4.13]# make****
**** The configure script must be executed before running 'make'.
**** Please run "./configure".
make: *** [makeopts] Error 1
[root@irongate asterisk-1.4.13]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.

Oops, no compiler. Easily fixed, yum –y install gcc and try again.

checking how to run the C++ preprocessor... /lib/cpp

configure: error: C++ preprocessor "/lib/cpp" fails sanity check

See `config.log' for more details.

They wonder why I like yum better. Ugg, google tells me I need c++ too, yum -y install gcc-g++. Take 3.

config.status: creating include/asterisk/autoconfig.h


            .$7$7..          .7$$7:.   

          .$$:.                 ,$7.7  

        .$7.     7$$$$           .$$77 

     ..$$.       $$$$$            .$$$7

    ..7$   .?.   $$$$$   .?.       7$$$.

   $.$.   .$$$7. $$$$7 .7$$$.      .$$$.

 .777.   .$$$$$$77$$$77$$$$$7.      $$$,

 $$$~      .7$$$$$$$$$$$$$7.       .$$$.

.$$7          .7$$$$$$$7:          ?$$$.

$$$          ?7$$$$$$$$$$I        .$$$7

$$$       .7$$$$$$$$$$$$$$$$      :$$$.

$$$       $$$$$$7$$$$$$$$$$$$    .$$$. 

$$$        $$$   7$$$7  .$$$    .$$$.  

$$$$             $$$$7         .$$$.   

7$$$7            7$$$$        7$$$     

 $$$$$                        $$$      

  $$$$7.                       $$  (TM)    

   $$$$$$$.           .7$$$$$$  $$     




configure: Package configured for:

configure: OS type  : linux-gnu

configure: Host CPU : x86_64

Well now isn’t that pretty and a good sign that I got it right on the 3rd try. Now I run make and after a spew of work on my session I get:

+--------- Asterisk Build Complete ---------+

 + Asterisk has successfully been built, and +

 + can be installed by running:              +

 +                                           +

 +               make install                +


Ok, if you insist, I guess I will make install.

+---- Asterisk Installation Complete -------+

 +                                           +


 +                                           +

 + Asterisk has successfully been installed. +

 + If you would like to install the sample   +

 + configuration files (overwriting any      +

 + existing config files), run:              +

 +                                           +

 +               make samples                +

 +                                           +

 +-----------------  or ---------------------+

 +                                           +

 + You can go ahead and install the asterisk +

 + program documentation now or later run:   +

 +                                           +

 +              make progdocs                +

 +                                           +

 + **Note** This requires that you have      +

 + doxygen installed on your local system    +


That’s it, I have it installed. Wait there’s more; a quick look at some other guides suggests I should get:

·         asterisk-addons-1.4-current.tar.gz

·         asterisk-core-sounds-en-gsm-current.tar.gz

I choose the gsm because they talked about gsm in the book a lot, I might need a different package but I will see.
It was time to dive into configuration, I remember the book was very thorough so I started going through the steps there. Back in the asterisk source directory, I did a make config to create the Fedora/Redhat style startup scripts. I also did a make samples to get the /etc/asterisk directory populated. Next I needed to get my 3102 configured so I used the Voxilla Configuration System to get the basics setup. I copied each of the suggested sections into the corresponding configuration files and then hit the Install Configuration button to handle the 3102 side of things. I was getting excited to I checked the Registration State field in the web voice configuration section and it said failed. I would hope so since we need to actually start Asterisk. I started Asterisk at the console with /usr/sbin/asterisk –cvvv. So far, so good. While I was fiddling around trying to figure out how to force the 3102 to register, I saw

*CLI> -- Registered SIP '101' at port 5060 expires 3600 in the background.

A quick check of the Voice Status page also showed

Registration State: Registered.

I edited the /etc/asterisk/extensions.conf and added an example from the book:

exten => 611,1,Answer()
exten => 611,2,Echo()

Note that this will be under the [home] heading instead of [internal] as the book shows since the Voxilla configuration sets the context to home. I also made a change to the dialplan on the 3102 to allow 611 [2-579]11<:@gw0> instead of [2-79]11<:@gw0>. Dialing 611 from my office phone put me into echo land like it should have. The sky is the limit from here; I am going to move on with voicemail, fwd and some of the examples in the book on my own.
It was a much shorter journey then I expected which I think is good. I always say start with a very basic working configuration and then add one little thing at a time. Good luck in your ventures with Asterisk.


  1. I spend a lot of time reading blogs and I have to say I'm impressed with your posts. It's refreshing to find a blog that has valuable content such as yours. I'll be a regular reader from now on, you can count on it.

  2. Thanks so much for your compliment. I always hope when I write that it will help someone else out there or be of interest. Glad to hear it's well received. Take care and thanks again for taking the time to let me know others are reading all of this.