Sunday, August 28, 2011

Lazy sip trunk with asterisk

In this scenario we are providing a sip trunk to connect two asterisk in different offices (Bangkok and Singapore), connected trough vpn already set up. Since we already have a secure firewall we won't be adding username authentication (otherwise we really should!). Bangkok have the extensions in the 6XXX range, Singapore in the 5XXX.

In BangkokÅ› side, we edit the file sip.conf and we add the following - changing ip for your host's one, trunk name, favorite codecs and context. That that last one I left it by default, so calling between PABX is enabled by default in both places (lazy way :)


  • In Bangkok's sip.conf:


[Singapore]
host = 10.9.9.1
username =
secret =
trunkname = singapore
group = null
hasexten = no
hasiax = no
hassip = yes
registeriax = no
registersip = yes
trunkstyle = voip
disallow = all
allow = g729,ulaw,gsm
insecure = port,invite
nat = no
qualify = yes
context = defaultDialPlan
careinvite = no
  • In Singapore's sip.conf:


[Bangkok]
host = 10.8.9.1
username =
secret =
trunkname = bangkok
group = null
hasexten = no
hasiax = no
hassip = yes
registeriax = no
registersip = yes
trunkstyle = voip
disallow = all
allow = g729,ulaw,gsm
insecure = port,invite
nat = no
qualify = yes
context = defaultDialPlan
careinvite = no

Now we have the sip trunk configured, we will create a digit map to be able to call.
  • Edit Bangkok's extensions.conf:
[InterPABX]
 exten => _5XXX,1,DIAL(SIP/Singapore/${EXTEN})
  • Edit Singapore's extensions.conf:
[InterPABX]
 exten => _6XXX,1,DIAL(SIP/Singapore/${EXTEN}) 
 After this, we need to add the InterPABX rule to the default dial plan in the extensions.conf in both sides:

[defaultDialPlan]
...
 [InterPABX]

We are done. Now we reload the sip and dialplan:


  • asterisk -rv
  •  BKK-asterisk-001*CLI>sip reload
  •  BKK-asterisk-001*CLI>dialplan reload
  •  BKK-asterisk-001*CLI>exit


Now we can grab a phone and make our first free call between our two places.

No comments:

Post a Comment