Prerequisites:
Lots of caffeine
Long finger nails (they will be short by the end)
Needing a hair cut (might be bald by the end)
Note: I am just joking about the prerequisites, I found it hard to get stuff right cause a lot of howtos out there are bit vague and cryptic. So here is my attempt to make it a bit easier for others to setup Asterisk and connect to a VoIP provider.
What is Asterisk:
Asterisk is software that turns an ordinary computer into a voice communications server. Asterisk is the world’s most powerful and popular telephony development tool-kit. It is used by small businesses, large businesses, call centers, carriers and governments worldwide. Asterisk is open source and is available free to all under the terms of the GPL.
Note:
For this howto we will be logged in as root, I take no responsibility to what may or may not damage or happen to your system.
Installing Asterisk:
# apt-get install asterisk
Under Debian Lenny this is the packages it will download and install. A lot of the packages it installs you may not need especially if you don’t need ‘vpb-driver-source’ for Voicetronix telephony hardware, but I will go into that later in the howto.
asterisk asterisk-config asterisk-sounds-main build-essential bzip2 ca-certificates cpp cpp-4.3 debhelper dpkg-dev g++ g++-4.3 gcc gcc-4.3 gettext html2text intltool-debian libasound2 libc-client2007b libc6-dev libcompress-raw-zlib-perl libcompress-zlib-perl libcurl3 libdigest-hmac-perl libdigest-sha1-perl libfile-remove-perl libgmp3c2 libgomp1 libgsm1 libiksemel3 libio-compress-base-perl libio-compress-zlib-perl libio-stringy-perl libltdl3 libmail-box-perl libmail-sendmail-perl libmailtools-perl libmime-types-perl libmpfr1ldbl libobject-realize-later-perl libogg0 libpq5 libpri1.0 libradiusclient-ng2 libsensors3 libsnmp-base libsnmp15 libspeex1 libspeexdsp1 libsqlite0 libssh2-1 libstdc++6-4.3-dev libsys-hostname-long-perl libsysfs2 libtimedate-perl libtonezone1 liburi-perl libuser-identity-perl libvorbis0a libvorbisenc2 libvpb0 linux-libc-dev make mlock module-assistant odbcinst1debian1 openssl patch po-debconf unixodbc vpb-driver-source
Backup:
First we need to make a backup of the sip.conf and extensions.conf files that we’ll be working with in this howto.
# mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bak ; mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bak
Now that we have moved the files we need to create a new sip.conf and extensions.conf files, change ownership and permission of them.
# touch /etc/asterisk/sip.conf ; chown asterisk:asterisk /etc/asterisk/sip.conf ; chmod 640 /etc/asterisk/sip.conf && touch /etc/asterisk/extensions.conf ; chown asterisk:asterisk /etc/asterisk/extensions.conf ; chmod 640 /etc/asterisk/extensions.conf
Configuration:
First of we are going to start with editing the sip.conf file with our favorite editor in my case nano.
# nano /etc/asterisk/sip.conf
This is basically what I have added to my sip.conf file. Stuff in bold is what you’ll have to change to what your VoIP provider has provided you and lines that start with ; are my notes and it how to comment out stuff.
; This section is how we are logging into our VoIP provider
[general]
register=account:password@sip00.mynetfone.com.au/account; This section is how outbound calls are handle to our
; VoIP provider and the codecs we want to use etc.
[MyNetFone]
username=account
type=friend
secret=password
qualify=yes
pedantic=no
nat=yes
insecure=port,invite
host=sip00.mynetfone.com.au
fromdomain=sip00.mynetfone.com.au
port=5060
fromuser=account
dtmfmode=rfc2833
disallow=all
canreinvite=no
authname=account
allow=g729
allow=alaw
allow=ulaw; This section is for how we connect to our VoIP provider for
; inbound calls.
[MyNetFone-In]
username=account
type=friend
secret=password
qualify=no
insecure=port,invite
host=sip00.mynetfone.com.au
fromuser=account
context=from-trunk
canreinvite=no; Below here is a user that has been create to be able to log
; into the Asterisk server for inbound and outbound calls via
; our VoIP provider.
[6678]
type=friend
secret=1234
host=dynamic
defaultip=192.168.0.22
dtmfmode=rfc2833
callerid=”tester” <6678>
Now onto the extensions.conf file, you’ll notice some things in this file that are referred to in the sip.conf file. Again with our favorite editor this is basically what I have added to the file. As before what is bold you have change to match details given to from your VoIP provider and what is commented out with ; are my notes
# nano /etc/asterisk/extenions.conf
; Handle calls coming in from our VoIP provider to Asterisk
; are directed to the extension 6678 on Asterisk
[from-trunk]
exten => account,1,Dial(SIP/6678,30)
exten => account,2,Congestion
exten => account,102,Busy; Sending all outbound calls with prefix 9 via our VoIP provider.
; Stripping the prefix 9 before sending call to VoIP provider.
; Dial 90881234567 will become 0881234567 for example.
[default]
exten => _9.,1,Dial(SIP/${EXTEN:1}@MyNetFone,30)
exten => _9.,2,Congestion
exten => _9.,102,Busy
Ok this basically does it for the 2 configuration file we had to play with to getting a connection to our VoIP provider.
Restarting Asterisk:
Now comes the fun part restarting Asterisk. This can be done a couple of ways.
First we can attach to the currently running Asterisk CLI by:
# asterisk -r
And you’ll get an output like this.
# asterisk -r
Asterisk 1.4.21.2~dfsg-3, Copyright (C) 1999 – 2008 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.
=========================================================================
This package has been modified for the Debian GNU/Linux distribution
Please report all bugs to http://bugs.debian.org/asterisk
=========================================================================
Connected to Asterisk 1.4.21.2~dfsg-3 currently running on localhost (pid = 32096)
localhost*CLI>
From here to restart Asterisk we type:
restart now
example:
localhost*CLI> restart now
Also Asterisk CLI is TAB auto complete friendly 🙂
The second way is depended on which ever way you prefer to restart services, in terminal to just type:
# invoke-rc.d asterisk restart
or
# /etc/init.d/asterisk restart
Is it working:
Now that we have restarted Asterisk, lets connect back into Asterisk’s CLI:
# asterisk -r
We need to now check that we have connected and logged into our VoIP provider and we do this by typing:
localhost*CLI> sip show registry
Example output:
localhost*CLI> sip show registry
Host Username Refresh State Reg.Time sip00.mynetfone.com.au:5060 account 105 Registered Wed, 16 Dec 2009 14:56:29
If we done everything correctly we should be able to make and receive calls through our VoIP provider from another computer or laptop with a softphone installed like Ekiga that is logged into the Asterisk server.
Clean Up:
As I mentioned earlier in this howto that there may packages installed that you not need for example ‘vpb-driver-source’ for Voicetronix telephony hardware. As I not needed it, to uninstall it and all the development and compiler packages all you need to do is:
# apt-get remove –purge build-essential bzip2 cpp cpp-4.3 debhelper dpkg-dev g++ g++-4.3 gcc gcc-4.3 gettext html2text intltool-debian libc6-dev libcompress-raw-zlib-perl libcompress-zlib-perl libdigest-hmac-perl libdigest-sha1-perl libfile-remove-perl libgmp3c2 libgomp1 libio-compress-base-perl libio-compress-zlib-perl libio-stringy-perl libmail-box-perl libmail-sendmail-perl libmailtools-perl libmime-types-perl libmpfr1ldbl libobject-realize-later-perl libstdc++6-4.3-dev libsys-hostname-long-perl libtimedate-perl liburi-perl libuser-identity-perl linux-libc-dev make module-assistant patch po-debconf vpb-driver-source
Ending:
Now that all the hard work is over and done with, can sit back with a beer and call up a mate and have a yarn(chat) and enjoy to spoils of having our own PBX. 🙂
Comments (0)