Wednesday, November 10, 2010

Basic Asterisk Configuration

Basic Asterisk Configuration

Filed under: Asterisk, Fedora Core, Telephony — Paul Skinner @ 1:29 am

I really like the stats package included with WordPress, it provides an excellent source of ideas for what I should write about next. Many of you reach me through a post titled Asterisk and Fedora Core 7 looking for more specifics on how to configure Asterisk. If you need to install Asterisk on FC7, read the Asterisk and Fedora Core 7 post first.



Alright, so you’ve got Asterisk installed but its not configured or has the default Asterisk sample configuration files.



The Asterisk configuration files are found in /etc/asterisk. If you are using Asterisk without telephony hardware, you really need to be concerned with 2 or 3 files. Of importance are the following files



1.sip.conf: this file contains everything to do with the SIP protocol, settings and authentication for Asterisk.

2.extensions.conf: At the most basic level, this file contains the call-plan; what happens on in-bound calls and how outgoing calls are to be treated.

You’re also going to need something to test Asterisk with. Either a soft-phone such as X-Lite or a handset device such as a Polycom 430, or a ATA device, such as the LinkSys PAP-2.



For the sake of this sample, we’re going to configure Asterisk to handle the SIP registration of 3 IP devices.



1.X-Lite Softphone [extension 203]

2.a Polycom 301 [extension 200]

3.a Linksys PAP-2 (Vonage un-locked) [extensions 201 and 202]

sip.conf is easy enough to get going; some advanced features found on some handsets may require additional settings but to keep things simple lets start with the softphone alone.



Backup your existing /etc/asterisk/sip.conf and go with something like this



[general]

port=5060

bindaddr=0.0.0.0

context=home

tos=0x18

nat=yes

externip=YOUR PUBLIC IP

disallow=all

allow=g729

allow=gsm

allow=ulaw



[203]

type=friend

host=dynamic

context=home

secret=agoodsippasswordgoeshere

callerid=CIA FBI ATF <1-555-555-5555>

dtmfmode=rfc2833

nat=yes

mailbox=200@home

disallow=all

allow=ulawFeel free to have some fun with the “callerid” parameter, you can have some great fun with your friends and family.



Make a backup of /etc/asterisk/extensions.conf and replace it with this



[general]



static=yes

writeprotect=no



[home]

exten => 55,1,Playback(demo-echotest) ; Let them know what's going on

exten => 55,2,Echo ; Do the echo test

exten => 55,3,Playback(demo-echodone) ; Let them know it's overThis bare bones configuration sets up extension 55 in the “home” context to be an echo server.



Get Asterisk to re-read the sip.conf and extensions.conf files (if already running, to start Asterisk, just run “asterisk” as root).



[root@athlon asterisk]# asterisk -r

Asterisk 1.2.20, Copyright (C) 1999 - 2007 Digium, Inc. and others.

Created by Mark Spencer

Asterisk comes with ABSOLUTELY NO WARRANTY; type '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 'show license' for details.

=========================================================================

Connected to Asterisk 1.2.20 currently running on athlon (pid = 3193)

Verbosity is at least 42

athlon*CLI> sip reload

Reloading SIP

== Parsing '/etc/asterisk/sip.conf': Found

== Parsing '/etc/asterisk/sip_notify.conf': Found

athlon*CLI> extensions reload

== Parsing '/etc/asterisk/extensions.conf': Found

-- Registered extension context 'home'

-- Added extension '55' priority 1 to home

-- Added extension '55' priority 2 to home

-- Added extension '55' priority 3 to home

athlon*CLI>
Configure the X-Lite phone by adding a SIP account with the following details:







Save the settings and X-Lite should register with Asterisk. If watching the Asterisk CLI, you should see the following



Connected to Asterisk 1.2.20 currently running on athlon (pid = 3193)

Verbosity is at least 42

-- Remote UNIX connection

-- Registered SIP '203' at 10.10.50.198 port 14126 expires 3600

-- Saved useragent "X-Lite release 1011s stamp 41150" for peer 203

athlon*CLI>



At this point you should be able to dial the echo server. Go ahead and dial “55″ and hit the green send button. You’ll connect with the “Echo Test”, basically just echoes whatever you say to it. It’s simple but a great way to get the basics right without having to deal with the large “sample” configuration files.



If your call to the echo server worked, the rest of the setup is basically the same as before, editing both the sip.conf and extensions.conf files.



Moving on, lets add the other extensions to the mix. We’ll have our own little PBX by the end of this!



Add the rest of the SIP devices to the sip.conf file



[general]

port=5060

bindaddr=0.0.0.0

context=home

tos=0x18

nat=yes

externip=YOUR PUBLIC IP

disallow=all

allow=g729

allow=gsm

allow=ulaw



[200]

type=peer

host=dynamic

context=home

secret=agoodsippasswordgoeshere

callerid= CITY MORGUE

dtmfmode=rfc2833

nat=yes

mailbox=200@home

disallow=all

allow=ulaw



[201]

type=friend

host=dynamic

context=home

secret=agoodsippasswordgoeshere

callerid= CITY MORGUE

dtmfmode=rfc2833

nat=yes

mailbox=200@home

disallow=all

allow=ulaw



[202]

type=friend

host=dynamic

context=home

secret=agoodsippasswordgoeshere

callerid= CITY MORGUE

dtmfmode=rfc2833

nat=yes

mailbox=200@home

disallow=all

allow=ulaw



[203]

type=friend

host=dynamic

context=home

secret=agoodsippasswordgoeshere

callerid=CIA FBI ATF

dtmfmode=rfc2833

nat=yes

mailbox=200@home

disallow=all

allow=ulawNow lets add the sip registrations to the extensions.conf file so that calls can be placed amongst the devices.



[general]



static=yes

writeprotect=no



[home]

exten => 55,1,Playback(demo-echotest) ; Let them know what's going on

exten => 55,2,Echo ; Do the echo test

exten => 55,3,Playback(demo-echodone) ; Let them know it's overexten => 200,1,Dial(SIP/200,20)

exten => 201,1,Dial(SIP/201,60)

exten => 202,1,Dial(SIP/202,60)

exten => 203,1,Dial(SIP/203,60)Reload sip.conf and extensions.conf and you should now be able to place calls between the registered devices and each device should be able to dial the echo server.



This is a very basic Asterisk configuration that should allow you to further explore other Asterisk options. In the next parts of this post, we’ll explore adding “trunking” with a VoIP provider, ZapTel hardware and voice mail with email notification (In no particular order).

No comments: