Asterisk Inbound & Outbound with your SIP provider

From open-voip.org

Jump to: navigation, search

After configuring the Asterisk Simple example we have calls between extentions.

now we will add the following functionalities with a SIP/DID provider:

  • Outbound calls with SIP provider
  • Register and get Inbound calls from your SIP provider
  • Get Inbound calls from your DID provider

the full conigurations files can be found below

Outbound calls with SIP provider

In order to configure outbound calls with you sip provider you need to know:

  • User, password
  • Provider Sip Server IP

I will use deltathree as the sip provider

  • User 11111111 pass 1234
  • Sip server: sipauth.deltathree.com

note it is a fake user and password. you will need a real user to test real call. you can test with this fake user but you will get an error announcement from the sip provider.

Add your provider to the sip.conf:

 [deltathree]
 context=from-sip                ; the context of this setup
 type=peer                       ; this peer is for outbound only
 host=sipauth.deltathree.com     ; IP/FQDN of your provider
 defaultuser=11111111
 secret=1234
 callerid="My PBX"               ; Set your Caller-id

Cahnge your dial-plan so dialing the preix "9" will dial out through your provider. the "from-sip" conext in the extensions.conf will be now:

 [from-sip]
 exten => _X.,1,Dial(SIP/${EXTEN},30)              ; calls between extensions
 exten => _9X.,1,Dial(SIP/${EXTEN:1}@deltathree)   ; 9 prefix will call out through deltathree 
                                                   ; not the "EXTEN:1" which dial out without the first digit (9)
 exten => _X.,2,hangup()

Register and get Inbound calls from your SIP provider

In Order to get inbound calls from your provider you need to know your number (DID) in addition to the user and password. in this example the DID is 12121111111

add the following line so asterisk will be registered with your provider and assosiate the user with extension 1000:

 register => 12121111111:1234:11111111@sipauth.deltathree.com/1000


Get Inbound calls from your DID provider

First we need to change the DID into the required extension, cahnge the from-sip context to:

 [from-sip]
 exten => 12121111111,1,Dial(SIP/1000,60)        ; direct inboound call from DID provider to specific extention
 exten => 12122222222,1,Dial(SIP/2000,60)        ; direct inboound call from DID provider to specific extention
 exten => _X.,1,Dial(SIP/${EXTEN},30)            ; calls between extensions
 exten => _9X.,1,Dial(SIP/${EXTEN:1}@deltathree) ; 9 prefix will call out through deltathree
 exten => _X.,2,hangup()

In order to have the inbound calls reach our "from-sip" context we have 2 options:

1. direct the numbers from the "default" context to the "from-sip" cotext, change extentions.conf to:

 [general]
 [globals]
 ;
 [default]
 exten => _X.,1,gosub(form-sip,${EXTEN},1)   ;direct inboound call from DID provider to specific extention
 exten => _X.,2,hangup()
 ;
 [from-sip]
 exten => 12121111111,1,Dial(SIP/1000,60)        ; direct inboound call from DID provider to specific extention
 exten => 12122222222,1,Dial(SIP/2000,60)        ; direct inboound call from DID provider to specific extention
 exten => _X.,1,Dial(SIP/${EXTEN},30)            ; calls between extensions
 exten => _9X.,1,Dial(SIP/${EXTEN:1}@deltathree) ; 9 prefix will call out through deltathree
 exten => _X.,2,hangup()
2. change the default context to "from-sip" by changing the context in the sip.conf file in the general section:
 [general]
 context=from-sip                  ; Default context for incoming calls


Links for the configuration files from the examples above:

Personal tools