Friday, 8 September 2017

How to configure sip and extensions files into Asterisk


 
In this article, we will learn how to configure basic sip.conf and extensions.conf files. These two files are very important configuration files. The sip.conf file holds sip channel related settings. We can define SIP users also in this file, if we dont use ARA (Asterisk Realtime Architecture). The extensions.conf file holds all extensions related information, extension means any number like 1000,1001 which we can dial by dial pad from our soft phone.

See, here SIP user is defined under certain context, and under that context extensions are defined. If you see below sip.conf file definition you can check 1000/1001 SIP users are defined under mycontext context. And in extensions.conf file you can see two extensions definitions are there under [mycontext]

So, we can see relation of SIP users and it's extensions, if SIP user defined under mycontext then that user can dial those extensions only which are defined under [mycontext]

Follow below steps to make basic configurations and make calling working

cd /etc/asterisk
mv sip.conf sip.conf.orig
mv extensions.conf extensions.conf.orig

nano /etc/asterisk/sip.conf and add below content in it and save
[general]
callcounter=yes ; enable device states for SIP devices
rtcachefriends=yes
udpbindaddr=0.0.0.0:5060
externip=your_public_ip
nat=force_rport,comedia
disallow=all
allow=opus
allow=ulaw
allow=alaw
allow=gsm
;you can add this if you don't have add Realtime SIP users
[1000]
type=friend
context=mycontext
secret=1234
host=dynamic
[1001]
type=friend
context=mycontext
secret=1234
host=dynamic 

nano /etc/asterisk/extensions.conf and add below content in it and save
[mycontext]
exten => 1000,1,Dial(SIP/1000)
exten => 1001,1,Dial(SIP/1001)

Now, goto asterisk cli and apply these commands.

asterisk -rvvvv
reload

Register two SIP users into two different soft phones like zoiper and dial each other, you will receive call and can answer.

No comments:

Post a Comment