How to set up Sip Trunk between two offices

1. Set up two Asterisk machines: Asterisk1 & Asterisk2
 
Example for Ubuntu:
vim /etc/network/interfaces
configure static ip address
/etc/init.d/networking restart
 
2. Log onto Asterisk1
 
vim /etc/asterisk/sip.conf
———– contents ——————–
[asterisk2]
type=friend
host={ip_address_of_asterisk2}
context=internal
insecure=invite (this is so that authentication is basing only on IP)
allow=all (or g729 codec only)
[1000]
type=friend
host=dynamic
context=internal
allow=all
secret={someComplexPasswordHere}
———————————————-
 
vim /etc/asterisk/extensions.conf
———– contents ——————–
[internal]
ext => 2000,1,dial(SIP/2000)
ext => 2000,n,Hangup()
 
exten => _1XXX,1,Dial(SIP/${EXTEN}@asterisk1)              (underscore meaning wildcards; {EXTEN} means any extension at asterisk2 server)
exten => _1XXX,n,hangup()
———————————————-
 
3. Log onto Asterisk2
vim /etc/asterisk/sip.conf
———– contents ——————–
[asterisk2]
type=friend
host={ip_address_of_asterisk1}
context=internal
insecure=invite (this is so that authentication is basing only on IP)
allow=all (or g729 codec only)
[2000]
type=friend
host=dynamic
context=internal
allow=all
secret={someComplexPasswordHere}
———————————————-
 
vim /etc/asterisk/extensions.conf
———– contents ——————–
[internal]
ext => 2000,1,dial(SIP/2000)
ext => 2000,n,Hangup()
 
exten => _1XXX,1,Dial(SIP/${EXTEN}@asterisk1)
exten => _1XXX,n,hangup()
———————————————-
 
4. Test
Use any SIP capable phone such as:
Blink
Ekiga
 
 
Commands for troubleshooting:
cat /etc/asterisk/extensions.conf  (cat command to read contents of file)
cat /etc/asterisk/sip.conf 
asterisk (start asterisk)
asterisk -r (reload asterisk settings)
sip reload (reload sip.conf)
dialplan reload (reload extensions.conf)
sip show users (show connected users)
sip show peers (to show all phones that are registered)
dialplan show (show dial plans)

Leave a Reply

Your email address will not be published. Required fields are marked *