fb

Instructions on how to configure VoIP equipment Asterisk

Setup manual / Asterisk
Setting up the Asterisk with Zadarma.

Information used in the example:

  • 111111 - Your sip-number from the personal account.
  • Password - You sip password found in the "SIP-settings" section of your personal account.
  • 101 - The Asterisk extension number that is connected to the softphone/IP phone.

Standard setup example

Outgoing calls from the extension number 101 are routed to the trunk 111111. Incoming calls are received by registration and are routed to extension number 101.

Editing sip.conf


[general]
srvlookup=yes

[111111]
host=sip.zadarma.com
insecure=invite,port
type=friend
fromdomain=sip.zadarma.com
disallow=all
allow=alaw&ulaw
dtmfmode=auto
secret=password
defaultuser=111111
trunkname=111111
fromuser=111111
callbackextension=111111
context=zadarma-in
qualify=400
directmedia=no
nat=force_rport,comedia


[101]                                                  ;the Asterisk extension number
secret=password
host=dynamic
type=friend
context=zadarma-out

Incoming and outgoing routing can be set up in the extensions.conf file


[zadarma-in]

exten => 111111,1, Dial(SIP/101)                       ; all incoming calls from trunk 111111
                                                       ; are routed to extension number 101

[zadarma-out]

exten => _XXX,1,Dial(SIP/${EXTEN})                     ; calls to 3-digit extension numbers
                                                       ; of Asterisk

exten => _XXX.,1,Dial(SIP/${EXTEN}@111111)             ; calls to numbers with 4 digits
                                                       ; or more using the trunk 111111

The standard setup is complete.

If you have several active virtual phone numbers, you can "name" each number (for example, Moscow and London) and set the incoming routing based on this parameter. The virtual phone number "Name" is displayed in theCALLERID(name) parameter.

In the following example, calls from the number named Moscow are routed to the extension number 101, and calls from the number named London are routed to the extension number 102. All other calls will be declined by the Asterisk with a "Busy" tone.


[zadarma-in]

exten => _X.,1,GotoIf($["${CALLERID(name)}" = "moscow"]?2:3)
exten => _X.,2,Dial(SIP/101)
exten => _X.,3,GotoIf($["${CALLERID(name)}" = "london"]?4:5)
exten => _X.,4,Dial(SIP/102)
exten => _X.,5,Busy

Your virtual phone number that received the call will be displayed in the CALLED_DID header. It is possible to configure incoming routing based on this parameter.

In the following example, calls from the number 74957776675 are routed to extension number 101, calls from the number 442037691880 are routed to extension number 102 and all other calls will be declined by the Asterisk with a "Busy" tone.


[zadarma-in]

exten => _X.,1,GotoIf($["${SIP_HEADER(CALLED_DID)}" = "74957776675"]?2:3)
exten => _X.,2,Dial(SIP/101)
exten => _X.,3,GotoIf($["${SIP_HEADER(CALLED_DID)}" = "442037691880"]?4:5)
exten => _X.,4,Dial(SIP/102)
exten => _X.,5,Busy


The setup is complete.

Example №2 (SIP URI)

If the Asterisk is located on a "white" IP address (not behind a router, for example in a data centre), incoming calls can be received without registration by a SIP URI scheme.

Information used in the example:

  • 15555555555 - Your virtual phone number connected to Zadarma.
  • 2.20.190.41 - your Asterisk server IP address.
Go to your personal account, "Settings - Virtual phone numbers" and route the calls from the virtual number to the external server (SIP URI) using this format: 15555555555@2.20.190.41

Editing sip.conf

[zadarma]
host=sipde.zadarma.com
type=friend
insecure=port,invite
context=zadarma-in
disallow=all
allow=alaw&ulaw
dtmfmode = auto
directmedia=no
nat=force_rport,comedia

[zadarma2]
host=siplv.zadarma.com
type=friend
insecure=port,invite
context=zadarma-in
disallow=all
allow=alaw&ulaw
dtmfmode = auto
directmedia=no
nat=force_rport,comedia

[zadarma3]
host=sipfr.zadarma.com
type=friend
insecure=port,invite
context=zadarma-in
disallow=all
allow=alaw&ulaw
dtmfmode = auto
directmedia=no
nat=force_rport,comedia
Incoming route is in the extensions.conf file

[zadarma-in]

exten => 15555555555,1, Dial(SIP/101)

The setup is complete.

Setup example using the authorization by IP address.