Thursday, April 15, 2010

SIP trunk between two Asterisk Servers

Let say I have two asterisk servers R01 and S01

; ****************
; *** SIP.CONF ***
; ****************
;
; Summary:
; - Configuration for SIP protocol
; - All phone registration information resides here
;
; Server: R01
; File location: /etc/asterisk/sip.conf
; *****************
;

[general]
disallow=all
allow=ulaw
canreinvite=no

register => trunk-S01-R01:welcome@[IP-add-of-S01]/trunk-S01-R01

[trunk-R01-S01]
type=friend
secret=welcome
host=dynamic
context=from-S01
;username=trunk-S01-R01

[1000]
type=friend
context=phones
host=dynamic
username=1000
secret=abc123



; ****************
; *** SIP.CONF ***
; ****************
;
; Summary:
; - Configuration for SIP protocol
; - All phone registration information resides here
;
; Server: S01
; File location: /etc/asterisk/sip.conf
; ***************
;

[general]
disallow=all
allow=ulaw
canreinvite=no

register => trunk-R01-S01:welcome@[IP-add-of-R01]/trunk-S01-R01

[trunk-S01-R01]
type=friend
secret=welcome
host=dynamic
context=from-R01
;username=trunk-R01-S01

[2000]
type=friend
context=phones
host=dynamic
username=2000
secret=abc123



DIALPLAN

;******************
;extensions.conf
;
;Server: R01
;******************

[globals]

[general]
autofallthrough=yes

[Internal]
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Dial(SIP/${EXTEN},30);
exten => _1XXX,n,Playback(the-party-you-are-calling)
exten => _1XXX,n,Hangup()

[External]
exten => _2XXX,1,NoOp()
exten => _2XXX,n,Dial(SIP/trunk-R01-S01/${EXTEN},30)
exten => _2XXX,n,Hangup()

[phones]
include => Internal
include => External

[from-S01]
include => Internal


;******************
;extensions.conf
;
;Server: S01
;******************
[globals]

[general]
autofallthrough=yes

[Internal]
exten => _2XXX,1,NoOp()
exten => _2XXX,n,Verbose(1,I am in Internal)
exten => _2XXX,n,Dial(SIP/${EXTEN},30)
exten => _2XXX,n,Hangup()

[External]
exten => _1XXX,1,NoOp()
exten => _1XXX,n,Verbose(1,I am in External)
exten => _1XXX,n,Dial(SIP/trunk-S01-R01/${EXTEN},30);
exten => _1XXX,n,Playback(the-party-you-are-calling)
exten => _1XXX,n,Hangup()

[phones]
include => Internal
include => External

[from-R01]
include => Internal


>Start Asterisk #asterisk
>Go to Asterisk Console #asterisk -rv
CLI> sip show peers
CLI> sip show registry

No comments:

Post a Comment