sip.conf file configuration
In the sip.conf file we can configure everything related
with the SIP protocol; add new sip users or define sip providers.
For example, and easy example of the sip.conf file:
[general]
context=default
port=5060 ; UDP port for Asterisk
bindaddr=0.0.0.0 ; If we want to specify only an IP
(if a computer has three different IPs) 0.0.0.0 means any
IP
srvlookup=yes ; Enable DNS SRV server
[peter]
type=friend
secret=welcome
qualify=yes ;latency must be under 2000ms.
nat=no ; Telephone without NAT
host=dynamic ; the devices can be registered with different
IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf
file
The sip.conf file starts with a [general] section with the
default configuration for every user and peer (providers).
The default values can be overwritten in the particular configuration
of each user or peer
- In general, SIP servers use port 5060 UDP. That is why we
use port=5060 . Sometimes, for
example if we use SER (Sip Express Router) with Asterisk we
should change the port number.
- DNS is a way to manage a logic adress in order to be resolve.
That allows, that calls can be led to different places without
changing the logic address. Using DNS SRV we have the advantages
of DNS whereas if we give the "no" value it is not
possible to route calls based in domains. It is a good idea
to active the service with srvlookup=yes
Each extension is defined by a user or a peer or a friend
and is called with a name between []
- "user" type is used to authenticate incoming
calls, "peer" for outcoming calls and "friend"
for both. In the example we have a "friend"
extension called "peter". It can make incoming and
outcoming calls.
- "secret" is the password used to authenticate.
In this case it will be "welcome"
- The latency between Asterisk server and the telephone can
be monitored with qualify=yes
to determine when the device can be reached. Asterisk considers
by default that a device is present if its latency is smaller
than 2000 ms (2 seconds). This value can be changed with the
number of milliseconds instead of "yes".
- If an extension is behind a device that makes NAT (Network
Address Translation) like a router or a firewall "nat=yes"
force Asterisk to ignore the field contact information and
it will use the address which the packages come from.
- If we put "host=dynamic"
means that the telephone will be able to connect from any
IP address. We can limit this user to access with only an
IP or a domain name. If we put "host=static" it
would not be necessary that the user will register itself
with the password provided in "secret".
- In SIP, invite messages are used to establish calls and
to redirect audio or video. Any invite message after initial
invite message in the same conversation is considered a reinvite.
For example, two users are connected and one of them active
Music on Hold (MoH) because he wants to stop the conversation.
Therefore, Asterisk make a reinvite to the second user. Later,
the first user wants to follow the call and send a reinvite
message to Asterisk and is sent to the second user and both
are again connected. Using canreinvite=no.
force Asterisk to be in the middle not allowing that the final
points interchange messages RTP directly.
Finally context=internal shows
the context where the instructions for this extension will
be executed. This is related to the context of the file extensions.conf
that gives the dialplan for that context. Therefore the "internal"
context must exist in the file extensions.conf or otherwise
we should not create it. Several extensions can have the same
context.
Advanced Options:
In the following columns we have the possibilities to configure
the "user" and "peer" types . In the case
of "friend" both columns are possible because a
friend is a user + a peer.
User |
Peer |
Explicación y opciones |
| context |
context |
Context in the dialplan (extensions.conf) for a peer
or a user. |
| permit |
permit |
Allow an IP address |
| deny |
deny |
Deny an IP address |
| secret |
secret |
Password for registration |
| md5secret |
md5secret |
Password with md5 |
| dtmfmode |
dtmfmode |
the way dtmf are sent. it could be "RFC2833"
or "INFO" |
| canreinvite |
canreinvite |
With"yes" Asterisk is forced to be in the
middle not allowing that the final points interchange
messages RTP directly. . |
| nat |
nat |
"yes" alert that the devices is behind NAT |
| callgroup |
callgroup |
Defines a callgroup |
| pickupgroup |
pickupgroup |
Defines a callgroup in a pickup() application |
| language |
language |
Defines a country signals and voices. It must be present
in the indications.conf file |
| allow |
allow |
allow a codec. Some codesc for the same user are possible.
values: "allow=all"
,"allow=alaw", "allow=ulaw", "allow=g723.1"
; allow="g729" , "allow=ilbc" , "allow=gsm". |
| disallow |
disallow |
disallow a codec. Some values that allow |
| insecure |
insecure |
Defines the way the connections with peers are managed.
It has these values very|yes|no|invite|port. "no"
is the default value that means that authentication is
compulsory. |
| trustpid |
trustpid |
If the Remote-Party-ID is trusted.
By default "no" |
| progressinband |
progressinband |
If inband signals must be generated. By default never
|
| promiscredir |
promiscredir |
Redirections 302 are supported. By default "no"
|
| callerid |
|
Defines the identifier when there is no other information
available |
| accountcode |
|
Users can be associated with an accountcode . For billing
purposes. |
| amaflags |
|
To CDR and billing purpouses It can be "default",
"omit", "billing", or "documentation" |
| incominglimit |
|
Limit of simultaneous calls |
| restrictcid |
|
To hide the caller ID. Deprecated |
| |
mailbox |
Voicemail extension |
| |
username |
If Asterisk acts like SIP client is the user name showed
to the calling SIP server. |
| |
fromdomain |
From field of SIP messages |
| |
regexten |
|
| |
fromuser |
User From field of SIP messages |
| |
host |
adress or host of the remote devices. it can be:
- An IP address or a host
- "dynamic" - any IP with password
- "static" - any IP without password |
| |
mask |
|
| |
port |
UDP port |
| |
qualify |
to determine when the device can be reached |
| |
defaultip |
default IP of the host= when "dynamic"
is selected |
| |
rtptimeout |
Timeout that ends the call when there is no RTP traffic |
| |
rtpholdtimeout |
Timeout that ends the call when there is no RTP traffic
on hold |
Ejemplos:
[grandstream1]
type=friend ; is both peer and user
context=mycontext ; context name
username=grandstream1 ; usually the same as the section
fromuser=grandstream1 ; overwrites caller-ID
callerid=John Smith<1234>
host=192.168.0.23 ; a private IP of a LAN
nat=no ; no NAT
canreinvite=yes ;
dtmfmode=info ; it can be RFC2833 or INFO
mailbox=1234@default ; mailbox 1234 in the context "default"
disallow=all ;
allow=ulaw ; allow alaw codec
; listed with allow= does NOT matter!
;allow=alaw
;allow=g723.1 ; Only g723.1 pass through
;allow=g729 ; Only g729 pass through
[xlite1]
;silence suppresion can be activated
;Xlite sends keep-alive NAT packets ,so qualify=yes is not
necessary
type=friend
username=xlite1
callerid="john jones" <5678>
host=dynamic ; xlite softphone could be in any IP address
nat=yes ; X-Lite is behind a NAT device
canreinvite=no ; when a device is behind a NAT device it usually
is no
disallow=all
allow=gsm ; GSM needs low bandwithd than ulaw and alaw
allow=ulaw
allow=alaw
[user1_snomsip]
type=friend
secret=blah ; password to register
host=dynamic
dtmfmode=inband ; the possibilities are inband , rfc2833,
or info
defaultip=192.168.0.59 ; IP address of the device
mailbox=1234; Voicemail
disallow=all
allow=ulaw ; because we have chosen inband for dtmf we need
alaw or ulaw (G.711)
allow=alaw
[user2_pingtel]
type=friend
username=user2_pingtel
secret=blah
host=dynamic
qualify=1000 ; If it is over 1 second without response the
connection is broken
callgroup=1,3-4 ; members of groups 1,3 and 4
pickupgroup=1,3-4 ; member of "pickup" groups 1,2
and 4
defaultip=192.168.0.60 ;IP
disallow=all
allow=ulaw
allow=alaw
allow=g729
[user3_cisco]
type=friend
username=user3_cisco
secret=blah
nat=yes ; is behind NAT
host=dynamic
canreinvite=no ;
qualify=200 ; 200 ms to receive a response
defaultip=192.168.0.4
disallow=all
allow=ulaw
allow=alaw
allow=g729
[user4_cisco1]
type=friendusername=user4_cisco
fromuser=peter ;
secret=blah
defaultip=192.168.0.4 ;
amaflags=default ; Possibilities are default, omit, billing
or documentation
accountcode=peter ; For billing purposes
disallow=all
allow=ulaw
allow=alaw
allow=g729
allow=g723.1
|