Configuring asterisk - a tutorial
April 18, 2018
Goal Overview
The system I am setting up is like this:Figure 1 - asterisk Network |
300x are devices, that is, SIP phones that can connect from anywhere on the Internet. They can be physical SIP telephones, or software clients running on PCs or smart phones. Most of my SIP devices are soft phones. I use X-Lite (on the PC/Mac) for testing and basic use. On Android phones, I use the Zoiper app. The SIP devices can make calls to one another, or to normal phones (rest of the world) by dialing out through the SPA 3000 ATA.
First, the installation. The instructions are sufficiently long to take up another post.
How asterisk works
Here, I will try to give a quick explanation of how asterisk works so that you can better understand the configuration steps that follow.Once asterisk is installed, the core system should work out of the box using the default settings. To make it do something useful, I have to modify two files: sip.conf and extensions.conf located in /etc/asterisk.
sip.conf
The out-of-the-box sip.conf contains lots of descriptive text. If you filter out all the commented lines (trygrep -o '^[^;]*' /etc/asterisk/sip.conf
), you will find that it contains only a few lines:[general]
context=public
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
transport=udp
srvlookup=yes
allowguest
is not in there, which means that the default allowguest=yes
is in effect. This will allow anonymous calls by anyone in the world (subject to your available dial plans) if your asterisk is exposed to the Internet!
To avoid corrupting the original sip.conf, I add this line to the bottom of the file:
#include sip_custom.conf
[general]
allowguest=no
nat=comedia
nat=comedia
because I have devices in and outside the LAN where asterisk is located, and I want to have conversations across the home router. The comedia
setting seems to solve the NAT problems of the past where the audio packets were sent to the public IP address of a device instead.sip.conf contains a list of channel (devices) definitions. For the most basic usage, we can treat each phone device as one channel. For a typical SIP device, I find that the following minimum works:
[3001]
secret=***password here***
context=from-internal
type=friend
dtmfmode=rfc2833
3001
is the name of the device. It is not the number that when dialed will reach this device, although for convenience usually everyone maps extension numbers to a device name of the same value. It is not restricted to digits, and can be alphanumeric.secret
is the password that together with the name will be needed at (the account settings of) your SIP device to log in (or register).context
is very important. It specifies the section in extensions.conf that will apply to calls dialed from this device.type=friend
means that asterisk can accept both inbound form and outbound to this channel.
Next, extensions.config.
Comments
Post a Comment