The SIP configuration file

This lesson is the first look into one of the configuration files that will need to be edited in Asterisk. Most of the configuration files for Asterisk will be located in the /etc/asterisk/ directory.

The SIP configuration file

There should already be a sip configuration file located at /etc/asterisk/sip.conf. Although we could decide to modify and use this file, it is often better to start with a new file from scratch. The original file can be moved with a new filename and used as a reference. First to move the existing sip.conf file use the following command:
sudo mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.sample

This moves the sip.conf file to a new file named sip.conf.sample.  Now a new file will need to be created name sip.conf. To do this you could use the following command:
sudo touch /etc/asterisk/sip.conf

The new sip.conf file will now be a blank text file.  To get started with the file there were are few default settings from the original sip file that would be a good idea to pass into this file. The edit the new sip.conf file use the command:
sudo nano /etc/asterisk/sip.conf

Add the following lines of code to the file, adding back the default configurations form the original sip.conf file. To save the file using nano use “ctrl+x” to save, then “y” to confirm, and “enter” to complete.
[general] context=public
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
transport=udp
srvlookup=yes

The [general] line of code indicates the context into which the following settings will apply. This is common with Asterisk configuration files. Basically all settings will be in the [general] context until a line with a new context is created. Later in the files each user will have their own context created.

The context=public line of code sets the default context for incoming calls to the [public] context that will be located in the /etc/asterisk/extensions.conf file. If this line of code was not present, the default context that phone calls would be directed to is [default].

The allowoverlap=no line of code tells Asterisk to expect to receive incoming phone digits one right after the other with very little delay between digits. The default value for allowoverlap is yes. If it is turned on then Asterisk will have a longer inter-digit timer (time-out period between digits entered) of approximately 2 seconds between digits.

The line of code udpbindaddr=0.0.0.0 sets the IPv4 address 0.0.0.0 for listening on UDP traffic. The address 0.0.0.0 is a special address that refers to all local IP addresses set on the server. If an Asterisk server had more than one network interface, and only one of the interfaces was used for Asterisk calls, that IP address could be set here. The default value is 0.0.0.0 and the default port number for SIP is port 5060.

The line of code tcpenable=no indicates to the Asterisk server whether or not to listen on TCP connections. The default value is no.

Similar to the updbindaddr, the line of code tcpbindaddr=0.0.0.0 sets the IP address to listen on TCP. If TCP was enabled, it would listen on port 5060 for TCP based traffic.

The line transport=udp sets the default transport layer protocol for SIP communication. The default is UDP.

The srvlookup=yes line of code tells the Asterisk service to look for a SRV record in the DNS server of a domain name. This is helpful with making phone calls to users that use a domain name rather than a telephone number. This works similar to how email uses an MX record to indicate servers for handling email addresses. The default value is yes.

One additional setting that can be added to the [general] context is the qualify setting. This will tell Asterisk to check if client is reachable. If qualify is set to yes, the checks occur every 60 seconds. The default value is no.