How To Configure Asterisk: Your First Installation
voip:/usr/src# apt-get install build-essential libssl-dev zlib1g-dev libncurses5-dev
Using Debian one can use apt-get to acquire the necessary packages. Other Liunx distros should use similar package names.
Download the latest 1.4 version of Asterisk from ftp.digium.com.
Note: Asterisk version 1.4.0 does have its issues, which can be show stoppers for larger installations. For this series of How To’s we will focus on Asterisk version 1.4.
Extract and compile the Asterisk source:
voip:/usr/src# tar zxf asterisk-1.4-current.tar.gz voip:/usr/src# cd asterisk-1.4.0 voip:/usr/src/asterisk-1.4.0# ./configure
The configure process will take a few minutes. When complete you can start building Asterisk.
voip:/usr/src/asterisk-1.4.0# make install
The compile process can take a little while, so go find yourself something to drink while the compiler does its magic.
Now that you are refreshed, we can get to configuring Asterisk.
The default configuration directory of Asterisk is /etc/asterisk/. We will need to create the following files.
logger.conf modules.conf sip.conf extensions.conf voicemail.conf
There are many many other configuration files, but only the above are required for our minimal configuration.
All Asterisk config files are very similar to .ini files. This makes for simple machine and human usage. For example:
[sample] keyword=value.
This would be considered the sample context and the keyword would be set to value.
Create each Asterisk config file.
logger.conf - Establishes the types of messages that you see on the CLI, Syslog or in discreet files. We will start by only sending messages just to the Asterisk CLI (console)
[logfiles] console = warning,notice,error
This instructs Asterisk to display the warning, notice and error message types. There is also a debug message type, however the amount of information that is generated is usually only interesting to a developer or someone attempting to diagnose a problem.
modules.conf - Instructs Asterisk which modules get loaded.
[modules] autoload=yes
More advanced configurations of Asterisk can disable the loading of specific modules. For this configuration the autoloading of modules is the simplest method to get started.
sip.conf - This details the SIP configuration for Asterisk. We will configure two SPA-942s and use a fictional account at the VoIP Provider that we have selected.
[general] port=5060 bindaddr=0.0.0.0 disallow=all allow=ulaw
[100] type=peer host=dynamic secret=100 context=users mailbox=100@default
[200] type=peer host=dynamic secret=200 context=users mailbox=200@default
[NuFone] type=peer host=proxy-1.nufone.net username=wilber fromuser=wilber secret=supersecure canreinvite=no
The above contexts define some general configuration details, plus 3 SIP entities.
The general context instructs Asterisk to use the common SIP port of 5060 and to bind to any available network port. The disallow and allow directives define the specific codec(s) that are to be used. For this configuration we will utilize only G.711 uLaw.
The 100 and 200 contexts define our two SP942 VoIP Phones.
host=dynamic instructs Asterisk that our SIP Phones will be registering to us, perhaps because they use a dynamically assigned IP address.
secret is the shared secret that we will use to authenticate each phone.
context is where in the dialplan (extensions.conf) calls for this device will get sent. We will discuss this option in more detail below.
mailbox defines the voicemail box to use. context is the specific extensions context to be used for this device.
The NuFone context defines the configuration as dictated by NuFone’s SIP Device Tutorial.
username and fromuser setup specific variables within the SIP protocol that allows NuFone to authenticate.
canreinvite=no is a specific option informing Asterisk to not attempt to re-invite or change any settings of the call. Re-invites are typically one cause of one-way audio or no audio at all, when behind NAT or firewalls.
extensions.conf - Extensions are groups of actions that instruct Asterisk exactly how to deal with your telephone calls. Extensions typically consist of a number of priorities containing multiple actions, which are grouped inside of contexts. Each context contains a logical grouping of actions (extensions) that make your dialing plan. The extensions concept of Asterisk is very flexible and powerful, which can be used to create complex telephony applications.
In this configuration, we establish two extensions for our SIP Phones and matching extensions to call out via NuFone using a layout that will provide the necessary foundation to build more complex dialplans in the future.
[macro-phone] exten => s,1,Dial(SIP/${MACRO_EXTEN},25) exten => s,n,Goto(${DIALSTATUS},1)
exten => ANSWER,1,Hangup exten => CANCEL,1,Hangup exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u) exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b) exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b) exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u) exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)
[stations] exten => 100,1,Macro(phone) exten => 200,1,Macro(phone)
exten => 4242,1,VoicemailMain(default)
[long-distance] exten => _NXXNXXXXXX,1,Dial(SIP/NuFone/1${EXTEN}) exten => _1NXXNXXXXXX,1,Dial(SIP/NuFone/${EXTEN})
[local] exten => _NXXXXXX,1,Dial(SIP/NuFone/1212${EXTEN})
[users] include => stations include => local include => long-distance
The macro-phone context defines a group of priorities that creates a standard telephone for our PBX. Utilizing a Macro avoids a serious amount of duplicated configuration and reduces mistakes when adding or changing features. We implement the detection of Busy and No Answer situations using the ${DIALSTATUS} channel variable and the Goto action. Hopefully, this gives you some early insight as to the power of the Asterisk Extension Logic. We will discuss the many uses of Channel Variables and Goto’s in future articles.
The stations context establishes the 100 and 200 extensions of our PBX. Future SIP Phones would get added into this context. We call the ‘phone’ Macro to provide each telephone similar a featureset without any duplicate configuration. We also define extension 4242 which allows you to check your voicemail.
The long-distance context establishes a matching pattern extension that matches any valid 10 or 11 digit telephone number. This is the standard method to dial long distance telephone numbers from the US or Canada.
The local context creates a matching pattern extension for local dialing. In this example we add ‘1212′ before sending the call out to match what NuFone expects. You will need to add your own local area code to make this code relevant for your situation.
The users context is a landing context. If you recall, in sip.conf we instruct Asterisk to use the users context for our two SIP phones — meaning calls from your SIP Phones will land in the users context. In this simple configuration, we include the stations, local and long-distance contexts. More advanced configurations could have other similar landing contexts to restrict certain phones from calling long-distance or to only call other stations, etc.
voicemail.conf - As you may have guessed, this file configures the voicemail boxes for your PBX.
[general] format=wav serveremail=voicemail@domain.name.tld attach=yes fromstring=Voicemail emailsubject=New Voicemail message ${VM_MSGNUM} emailbody=A ${VM_DUR} long message from ${VM_CALLERID}, on ${VM_DATE}\n emaildateformat=%A, %d %B %Y at %H:%M:%S
[default] 100 => 100,Mailbox 100,valid@email.address.com 200 => 200,Mailbox 200,another_valid@email.address.com
The general context defines the most common settings.
You need to set a valid serveremail value to ensure your mail agent will deliver the email.
attach=yes tells Asterisk you want to attach the actual voicemail recording to the email that gets sent out.
fromstring is the From header that the email will appear to be sent by.
The emailsubject, emailbody and emaildateformat are highly configurable using built in variables.
The default context defines the actual mailboxes using the format of:
mailbox => password,Mailbox Name, Email Address to send voicemail notification
Set valid email addresses to ensure proper email delevery.
You can now start Asterisk for the first time.
voip:/etc/asterisk# asterisk -vvvgc
Leave Asterisk running. Lets now configure the twp SPA-942s to communicate with your Asterisk PBX.
Determine the IP Address of the SIP phone. The simplest way is to press the configuration button and scroll down to the network option (or press 9).
We will be configuring these SIP Phones using their web interface. Point your favorite web browser to the IP address you just determined.
In the upper right hand section click on the Admin Login link and then click on the advanced link. This will provide more configuration options, which we will need to utilize.
Starting on the SIP tab, set Handle VIA Received and Handle VIA rport to Yes in the NAT Support Parameters. Handle VIA Received instructs the SIP phone to respond to the appropriate server, which called VIA in the SIP Headers. Handle VIA rport tells the SIP phone to communicate using the ‘rport’ value. These two settings assist the SIP Phone in dealing with NAT and/or Firewall situations.
On the Phone tab, set a Station Name and set the Short name on Line Key 1 to “Line 1″, otherwise the default setting may confuse less technically savvy users, in my opinion.
On the Ext1 tab, set the Proxy to the IP or hostname of your Asterisk box and set both the User ID and Password to 100 (200 for the second SIP Phone). In the Audio Configuration section ensure that G711u is selected.
Click on Submit All Changes and your phone will reboot. When it comes back on-line you should be registered with your Asterisk PBX and can call to the other SIP Phone or out via NuFone.
I hope this has provided you with a solid understanding of how to compile and configure a simple installation of Asterisk. Granted this is not by any means a comprehensive guide to Asterisk. However, this How To should get you up to speed, allowing you to deploy a more advanced configuration of Asterisk without such a steep learning curve.
Comments
For As Low As $6.99 Per Month You'll Get:
- Free USA Local Phone Number
- Free Phone Adaptor (worldwide shipping for only $4.99)
- Free $30 International Call Bonus
- Free PC to Phone Softphone Dialer
- Free Virtual Calling Card
- Free Calling Features
- Amazing Low Rates
For more information, please visit tipidIDD website:
http://tipididd.blogspot.com/
VoIP, Cheap IDD, Broadband Phone, Free Call, free voip, internet telephony voip, stunt voip, tipid idd, tipididd, voip, voip pbx, voip phone, voip phone system, voip service, voip solution, vonage voip, bayanwireless, pldt, digitel, bayantel, smart, globe, globelines, pldtplus, pinoy voip, philippine voip