≡ Sip.conf Explained

Asterisk’s sip.conf file, located in /etc/asterisk is the file you use to setup a SIP trunk. We’re going to walk through setting up a trunk with your VoIP provider so you can make/receive calls.

First, we’ll setup a general context. Context are defined as: [context_name]. Then, any rules for that context follow directly below. Anything in the general context will apply to every other context.

[general]
context=default
bindport=5060
port=5060
bindaddr=0.0.0.0 ; if you have more than one NIC, change this to the IP you want to use
disallow=all
allow=ulaw
allow=gsm
useragent=Asterisk PBX
register => USERNAME:PASSWORD@SIPPROXY.COM/yourhandle

Note the register string. Here, you need to enter your SIP username and password, and the url of their SIP proxy. Contact your provider for specifics. The /yourhandle syntax is special. You can write something like /sip1, and then use that reference in extensions.conf - I’ll add more details on this in an extensions tutorial; it won’t make much sense yet…

Next, we’ll create a trunk so we can make and receive calls. This will be referenced in extensions.conf later on.

[mytrunk]
type=friend
authuser=USERNAME
fromuser=USERNAME
username=USERNAME
secret=PASSWORD
insecure=very
host=YOURSIPPROVIDER.COM
fromdomain=YOURSIPPROVIDER.COM
qualify=3600
nat=no ; change to yes if you are behind NAT
bindport=5060
bindaddr=0.0.0.0
context=default

Now, you’ll need to add an extension for your phone to register to Asterisk with.

[1000]
type=peer
callerid="Your Name" <1000> ; this will only work in-network
username=1000
secret=ANYPASSWORD ; change this to any password you want to use
host=dynamic
nat=yes ; allow for connections behind NAT
disallow=all
allow=ulaw

Now, you can register an ATA or softphone to your Asterisk box using 1000.

That’s about it for sip.conf. Post a comment if you have questions or are lost.

– the evil genius