Anyone who has worked with Asterisk will have undoubtedly realized the ease of implementation it can bring to setting up simple VoIP systems. However, after some period of time, a desire to expand the system will arise. The most common way of expanding these types of configurations is to add multiple servers in an inter-connected fashion. In most installations of Asterisk, SIP connections will be the preferred method of communication. Trunk connections between asterisk servers can be made with a variety of protocols. In this guide trunk connections will be made via IAX2 connections.
For the creation of this guide, an AsteriskNOW v1.5 turn-key installation server system was used. This makes use of the Asterisk 1.4 server as its backend. Installation of all major and required components is included as well as a common web interface for administering the system, FreePBX. The local extensions for any given server are all basic SIP device connections with no special configurations.
As with most system implementations, a design will be required as a starting point. When determining the layout of the VoIP network to be constructed, it is often suggested that a dial plan be considered as well. A conscious dial plan design will make the rest of the implementation much easier. The most common that results is that each physical location will end up with distinct extension subsets (e.g. Location A get extension 3XXX, Location B gets extensions 4XXX, and Location C gets extensions 5XXX). Maintaining inter-server dial patterns is much easier with this sort of design, although it is not required. This guide assumes the layout of the VoIP network will be configured as follows:
Master Server:
Hostname: master.voip.domain.ext
Extensions: 2XXX
Slave 1:
Hostname: slave01.voip.domain.ext
Extensions: 3XXX
Slave 2:
Hostname: slave02.voip.domain.ext
Extensions: 4XXX
The reasons for organizing any particular VoIP network in any particular way will usually be simply the preference of the person(s) that are building the system. The more organized and structured things are, the less difficult they will be to maintain later.
The first step is to setup all 3 servers for individual use. All 3 servers need to function independently. Completely install the Asterisk server system on each machine, and then ensure it is able to add an extension or 2 and make calls internally between extensions. Don’t forget the extension layout and dial plan that was created earlier. Its also a good idea to test that each server can connect to an external DID provider and make calls to an external phone network. If a DID provider is not available it is not absolutely to test this at this point on all servers as only the master server will require this type of connection.
Once all three machines have been configured as stand-alone servers, we are able to setup the trunk connections between the servers. All of the servers in the network will require knowledge of each other in order to direct calls to the correct location(s).
Trunks on master.voip.domain.ext in iax_custom.conf:
register => master:IAXpa$$@slave01.voip.domain.ext
register => master:IAXpa$$@slave02.voip.domain.ext
[slave1] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
[slave2] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
Trunks on slave01.voip.domain.ext in iax_custom.conf:
register => slave1:IAXpa$$@master.voip.domain.ext
register => slave1:IAXpa$$@slave02.voip.domain.ext
[master] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
[slave2] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
Trunks on slave02.voip.domain.ext in iax_custom.conf:
register => slave2:IAXpa$$@master.voip.domain.ext
register => slave2:IAXpa$$@slave01.voip.domain.ext
[master] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
[slave1] ; peer name
type=friend
host=dynamic
trunk=yes
nat=yes
secret=IAXpa$$
context=from-internal
This trunking setup provides every asterisk server with direct knowledge of every other server within the network. Save these settings in each server and reload asterisk on each server to have all the trunk connections established. This can be verified by typing ‘iax2 show peers‘ into the asterisk CLI. Once the trunks have been established, dial patterns need to be added to direct calls from one location to another where appropriate.
As indicated before, this example will assume that all extensions on master.voip.domain.ext are in the 2XXX range, slave01.voip.domain.ext in the 3XXX range, and slave02.voip.domain.ext in the 4XXX range.
Dial patterns on master.voip.domain.ext in extensions_custom.conf:
exten => _3XXX,1,Dial(IAX2/slave1/${EXTEN})
exten => _4XXX,1,Dial(IAX2/slave2/${EXTEN})
Dial patterns on slave01.voip.domain.ext in extensions_custom.conf:
exten => _2XXX,1,Dial(IAX2/master/${EXTEN})
exten => _4XXX,1,Dial(IAX2/slave2/${EXTEN})
Dial patterns on slave02.voip.domain.ext in extensions_custom.conf:
exten => _2XXX,1,Dial(IAX2/master/${EXTEN})
exten => _3XXX,1,Dial(IAX2/slave1/${EXTEN})
After adding the dial patterns and reloading the asterisk servers one last time, calling an extension on any server from any other server should no complete the call.
Lastly, a few notes about this type of setup. The IAX2 trunks are bi-directional and make use of the “friend” type instead of the “user/peer” model. This was chosen due to simplicity of setup and troubleshooting. The trunks are all entered with the option ‘nat=yes’, this is not required if all servers are on the same LAN. Also, all servers within the network deliver calls to each other from the ‘from-internal’ context. This allows each server to treat calls from other servers as if they come from an internal extension. If necessary this can be changed in the trunk settings, however, a dialing macro will be needed to accommodate the change. Finally, in the configuration explained here, only server-to-server calling has been setup. Removing the common “_9|.” dial pattern (for outbounds calls) and adding one for “_9.” (no ‘|’) that directs the slave server to Dial(IAX2/master/${EXTEN}) will redirect outbound calls to the master server without removing the leading 9. Maintaining the leading 9 will direct the master server to place the call as an outbound call.
Leave a Comment