fb

Asterisk with authorization by IP adress

Example how to set Asterisk with Zadarma by authorization bu IP address.

If the server running Asterisc is using a "white" IP address (not behind a router, but, for example, in a data center), outgoing calls can be made without a sip login and password, with IP authorization. Incoming calls can be received without registration with SIP URI.

Key to the information which appears in the example:

  • 15555555555 - Your Zadarma phone number.
  • 2.20.190.41 - IP address of your Asterisk server.
  • 101 - Asterisk's Internal number to which softphone/IP-phone is connected in order to receive incoming calls and to make outgoing calls.
In your personal account, under "Settings - Direct phone number" route calls from DID number to an external server (SIP URI) using the format 15555555555@2.20.190.41

Adding SIP-trunk:

In your personal account, under "Settings - SIP-settings", click on "Add SIP-trunk" (appears at the bottom of the page).

Set a name for the SIP-trunk and choose one of the exisiting sip logins. This will be the SIP-trunk identificator and will be unavailable for registration (receiving incoming calls ).

Add your static IP address or several IP addresses (for example if your PBX is connected to 2 Internet channels: main and reserve).

In order to verify your IP address, it is necessary to route a call to the server sip.zadarma.com through the number 8888

After your IP address verification, you will be able to make outgoing calls by sending INVITE to us with your desired CallerID number in From: field. This makes the setup with multiple numbers significantly easier, and simplifies the understanding of the outgoing routing process.

Edit sip.conf

[general]
srvlookup=yes

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

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

[zadarma3]
host=siplv.zadarma.com
fromdomain=sip.zadarma.com
type=friend
insecure=port,invite
context=zadarma-in
disallow=all
allow=alaw&ulaw
dtmfmode = auto
directmedia=no

[zadarma4]
host=sipfr.zadarma.com
fromdomain=sip.zadarma.com
type=friend
insecure=port,invite
context=zadarma-in
disallow=all
allow=alaw&ulaw
dtmfmode = auto
directmedia=no

[101]                                               
secret=password
host=dynamic
type=friend
context=zadarma-out

Calls routing is set in file extensions.conf

[zadarma-in]
;incoming calls are routed on internal number 101
exten => 15555555555,1, Dial(SIP/101)                 

[zadarma-out]

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

;CallerID setup 15555555555
exten => _XXX.,1,Set(CALLERID(num)=15555555555)         
same => n,Dial(SIP/zadarma/${EXTEN})

Setup is finished.