Example of setting (asterisk SIP-trunk)

Example of connecting asterisk via SIP-trunk to our softswitch:

/etc/asterisk/sip.conf

; == With registration
; We recommend registering on both servers

register => tt:password@sip1.voipgw.com
register => tt:password@sip2.voipgw.com

[tt1]
type=peer
username=tt
secret=password
host=sip1.voipgw.com
nat=no
;canreinvite=yes ; asterisk version 1.2+
directmedia=yes ; asterisk version 1.8+
dtmfmode=rfc2833
qualify=500
disallow=all
allow=alaw
allow=ulaw
allow=g729
context=context
 

[tt2]
type=peer
username=tt
secret=password
host=sip2.voipgw.com
nat=no
;canreinvite=yes ; asterisk version 1.2+
directmedia=yes ; asterisk version 1.8+
dtmfmode=rfc2833
qualify=500
disallow=all
allow=alaw
allow=ulaw
allow=g729
context=context

> sip show registry
Host                            Username       Refresh State               
sip1.voipgw.com:5060              tt                  45 Registered
sip2.voipgw.com:5060              tt                  45 Registered  

/etc/asterisk/extensions.conf

Without re-routing:
exten => _X.,1,Set(CALLERID(num)=372XXXXXXX) ; where 372XXXXXXX  - CallerID
exten => _X.,n,Dial(SIP/${EXTEN}@tt1,,g)
exten => _X.,n,Hangup

With re-routing:
exten => _X.,1,Set(CALLERID(num)=372XXXXXXX) ; where 372XXXXXXX - CallerID
exten => _X.,n,Dial(SIP/${EXTEN}@tt1,,g)
exten => _X.,n,ExecIf($["${DIALSTATUS}" == "ANSWER"]?Hangup(${HANGUPCAUSE}))
exten => _X.,n,ExecIf($["${DIALSTATUS}" == "NOANSWER"]?Hangup(${HANGUPCAUSE}))
exten => _X.,n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup(${HANGUPCAUSE}))
exten => _X.,n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Hangup(${HANGUPCAUSE}))
exten => _X.,n,Dial(SIP/${EXTEN}@tt2,,g)
exten => _X.,n,Hangup(${HANGUPCAUSE})

; == IP-based authentication:
[tt]
type=peer
host=sip.voipgw.com
nat=no
;canreinvite=yes ; asterisk version 1.2+
directmedia=yes ; asterisk version 1.8+
dtmfmode=rfc2833
qualify=500
disallow=all
allow=alaw
allow=ulaw
allow=g729
context=context

/etc/asterisk/extensions.conf

exten => _X.,1,Set(CALLERID(num)=372XXXXXXX) ; where 372XXXXXXX - CallerID
exten => _X.,n,Dial(${EXTEN}@tt,,g)
exten => _X.,n,Hangup(${HANGUPCAUSE})