Configuring Asterisk – Part 1
Tools like Asterisk@HOME and FreePBX make the process of configuring an Asterisk box incredibly easy. They have pretty web-based user interfaces, downloadable modules, and generally just make things easy to do. If anyone has managed to get a package to run freePBX on OpenWRT sorted, I’d love to hear about it. Until then though, it’s all done through the files. Which is not as difficult as you might imagine, once you get the hang of it.
I break everything in Asterisk into one of three categories – I’m sure someone will tell me I’m wrong on this – Extensions, Trunks and The Rules. These categories have may or may not be related to do with the names of the files that they are configured from, they are just the way I think about this stuff.
Extensions – These are the actual telephone(s) that are connected to your PBX
Trunks – these are the connections from your PBX to the outside world and/or other peoples PBX’s
The Rules – these are the bits which make everything work.
The easiest place to start is probably setting up extensions. In my case, I’m using a Linksys PAP2T to provide two local extensions. The set up of each of these is a two step process :
- Configure asterisk to take a SIP connection
- Configure the PAP2T to connect to Asterisk
My Asterisk box is running on an Accton MR3201a at 192.168.0.30, my PAP2T is configured to use DHCP, usually 192.168.0.50. To configure the Asterisk end of the connection ssh into the MR3201 and edit sip.conf using vi. First though a note on Asterisk configuration files.
Asterisk has a whole bunch of configuration files, most of them contain stuff that I’ll probably never need to worry about or change. Fortunately Asterisk lets me include one config file from another. When I want to change or add to sip.conf for example, I have just added the line
#include sip_local.conf
to the end of the file, and make all my changes in sip_local.conf so that they are easier to find and manage. Anyway, back to connecting the PAP2T to Asterisk …
~> ssh root@192.168.0.30
root@192.168.0.30's password:
BusyBox v1.4.2 (2007-07-23 05:59:27 CEST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
KAMIKAZE (7.07) -----------------------------------
* 10 oz Vodka Shake well with ice and strain
* 10 oz Triple sec mixture into 10 shot glasses.
* 10 oz lime juice Salute!
---------------------------------------------------
root@OpenWrt:~# cd /etc/asterisk/
root@OpenWrt:/etc/asterisk# ls
agents.conf extensions.conf modules.conf
alarmreceiver.conf extensions_demo.conf musiconhold.conf
asterisk.conf extensions_local.conf osp.conf
cdr.conf features.conf privacy.conf
cdr_custom.conf iax.conf queues.conf
cdr_manager.conf iax_local.conf rtp.conf
codecs.conf iaxprov.conf sip.conf
dnsmgr.conf indications.conf sip_local.conf
enum.conf logger.conf sip_notify.conf
extconfig.conf manager.conf sip_registrations.conf
extensions.ael misdn.conf
root@OpenWrt:/etc/asterisk# vi sip_local.conf
I’m going to assume that you know how to use vi – if you don’t try installing joe, which at least gives a help screen when you press Ctrl-K Ctrl-H
<code>ipkg install joe</code>
The first entry in my sip_local.conf is
[1000]
type=friend
secret=PASSWORD
qualify=yes
nat=yes
host=dynamic
context=from-internal
canreinvite=no
callerid=device <1000>
The [ ] is a section header in most configuration files, in this case [1000] sets the SIP user name.
- type=friend means that this device will be able to send and receive calls, other options are peer and user
- secret=PASSWORD is pretty obvious
- qualify=yes tells asterisk to regularly ping the connection to make sure it’s latency isn’t to high for VOIP operations
- nat=yes tells asterisk that the device is behind a NAT firewall
- host=dynamic tells asterisk that the device may change its IP address, and will tell us where it is. You could also put a static IP address here.
- context=from-internal tells Asterisk what context to start in when processing The Rules – we’ll get to that later
- canreinvite=no does something that I understand but can explain in one sentence try here for more detail
- callerid=device <1000> sets the caller id for the device
I have two entries like this set up, one for each of the two channels on the PAP2T
To set the PAP2T, login to the web interface as adiministrator and set the SIP proxy to the address of the MR3201a (192.168.0.30) in my case, the User name to 1000 and the password to the one specified above. this is obviously repeated for each channel as well.
Now, plug in a telephone (or two) and asuming everything is ok, nothing at all will happen – since no extensions are set up yet.
To test that things are working, add the following to extensions_local.conf (remember to add a #include to extensions.conf as well)
[from-internal]
exten => 1000,1,Dial(SIP/1000)
exten => 1001,1,Dial(SIP/1001)
Now pick up extension 1000 and dial 1001, extension 1001 should ring – you may need to get Asterisk to reload it’s configuration before this will work.
The next post will explain how to set up a SIP trunk to Pennytel, and after that, we’ll get into some detail with The Rules
Possibly Related Posts:
- Parental Controls – Wrapping things up
- Parental Controls and XCode
- Parental Controls – First Impressions
- OSX Parental Controls
- Configuring Asterisk – Part 4
Comments
Comment from loom
Time: 2 February 2009, 1:24 pm
I haven’t seen anything yet. The biggest problem is going to be the limited capacity of the on board flash. I’m looking into mounting a NFS share to provide things like freepbx, voicemail, etc.
Right now, I’m sticking with the asterisk config files though, which provide pretty much everything that you can do through freepbx.
Comment from ferraminnoff
Time: 13 February 2010, 10:02 am
Yes undoubtedly, in some moments I can phrase that I approve of with you, but you may be in the light of other options.
to the article there is still a suspect as you did in the downgrade issue of this request http://www.google.com/ie?as_q=cover xp pro 1.6 ?
I noticed the utter you procure not used. Or you profit by the dreary methods of development of the resource. I take a week and do necheg
Your Ferrdenants
Comment from arlekilop
Time: 21 February 2010, 4:08 am
Yes indeed, in some moments I can bruit about that I approve of with you, but you may be considering other options.
to the article there is quiet a definitely as you did in the go over like a lead balloon a fall in love with publication of this request http://www.google.com/ie?as_q=ps3 cell chip ?
I noticed the utter you suffer with not used. Or you use the dark methods of promotion of the resource. I have a week and do necheg
Your aferanas

Comment from d
Time: 31 January 2009, 6:52 am
Do you have a news on installation freepbx?