Hack56.Link Several PBXs over the Internet

Hack 56. Link Several PBXs over the Internet

Since wide area networking is the cornerstone of IP networking, VoIP can be extended outside the local area network. Six PBXs on six continents all managed by one person? No problem.

One of the beauties of VoIP is the last two lettersIP. IP stands for Internet Protocol, and IP is the protocol that makes the Internet and private wide area networks (WANs) possible. It provides the fundamental addressing and routing scheme that keeps data traffic flowing around the globe.

Just as people have been setting up VPNs to link remote offices' LANs over the Internet, you can now use the Internet to link several remote PBXs to create one large interconnected voice network. This will enable extension-to-extension calling from one office to another, over the Internet, all at no cost per call. Asterisk is the perfect solution for this purpose.

Keeping VoIP secure as it travels the globe is no simple matter. You can use Internet-based VPNs, but they can degrade quality. A more expensive and more reliable alternative to secure global VoIP trunks might be a managed VPN service or a frame relay service.

I will assume that you already have Asterisk in use as the PBX at all of your offices. If this is not the case, you might want to look into setting up an Asterisk gateway machinea server that provides VoIP enablement for a legacy PBX (see "Build a Four-Line Phone Server" [Hack #49] and "Connect a Legacy Phone Line Using Zaptel" [Hack #44] for ideas on how to use legacy TDM interface cards).

Now let's assume:

  • You have three offices: one in Chicago, one in Tokyo, and one in London.

  • None of the offices has more than 99 separate extensions.

  • They all have 24/7 Internet connectivity.

  • They all have static IP addresses.

  • Their Asterisk installs are directly on the Internet, or the network administrator has forwarded/passed UDP port 4569 to the Asterisk server in each location.

It is worth pointing out that the last three items do not necessarily have to be the case. With all of Linux's power, you can actually work around those issues. While this is too much information for me to cover here, you can use the "register" feature of IAX with dynamic IP addresses, even those behind NAT! A simple Google search should return the necessary details to use register statements successfully to work around those problems.

Let's also assume that none of your locations has overlapping extensions. That is, each location has globally unique extension numbers. For the purposes of this hack, we are going to assume that your extensions are set up like so:


81XX (where XX is 0199)





So your first extension in Chicago is 8101, and your last possible extension in London is 8399.

If your extensions are not set up like this, it will probably be to your advantage to renumber. As you will see, this method has one big advantage: unless every extension is globally unique, it's more difficult for each Asterisk server to route calls.

The beginning "8" signifies an internal extension. I begin with this to standardize on four-digit extensions so that an internal extension is readily recognized as being a free internal call, as opposed to an outside call to the pizza place. (This prefix helps Asterisk figure out where to route the callto an internal user or to the phone company.) Using the same numbering convention around the world will make your life easier. When you bring that new office in Stockholm online, you just have to assign it the 84XX range and update your Asterisk servers, and the phones around the world will automatically recognize it as a valid range.

If you have not already done so, let's set up some basic DNS records for this system. We are going to create several A records in our existing DNS zone, twidgets.com. These A records are going to be called chicago.twidgets.com, tokyo.twidgets.com, and london.twidgets.com. They should each point to the static IP address of the Asterisk server at each respective location.

Once DNS is set up properly, verify basic IP connectivity by using the ping command to each location, from each location. Ping Tokyo from Chicago and London. Ping London from Tokyo. You get the drift. This is what you should have so far:

Table 4-2.



Extension block










4.17.1. Configuring the Dial Plan

On each Asterisk server, you need to add a matching extension for each dial pattern. So, log into your server in Chicago and add the following to your [internal] context in /etc/asterisk/extensions.conf:

 exten => _82XX,1,Dial(IAX2/guest@tokyo.twidgets.com/${EXTEN},20) exten => _82XX,2,Congestion exten => _83XX,1,Dial(IAX2/guest@london.twidgets.com/${EXTEN},20) exten => _83XX,2,Congestion 

Let's take a look at what we have done so far. In the first line, we're telling Asterisk to create an extension that matches anything in the 82008299 range. (Remember those X's from before? They signify to Asterisk any digit between 0 and 9.) The first thing that Asterisk should do is try to reach that extension at the Tokyo office by using the IAX protocol (Version 2) with the username guest. The guest username is just a placeholder. You can use a more descriptive name if you want.

The IAX protocol is a signaling protocol, like SIP, which is more efficient at trunking multiple simultaneous calls between the same two locations.

If that extension at the Tokyo office is unreachable for any reason, Asterisk will return congestion. Congestion is usually signaled to the user as what is called "fast-busy." If you have ever left a POTS phone off the hook for too long, you have heard a fast-busy.

4.17.2. Adding the Remote Locations

Save extensions.conf and reload Asterisk with asterisk -rx reload. If the servers in Tokyo and London have been set up with those extensions, go ahead and try calling them. They won't be able to call you back yet, but you should at least be able to verify that you now have direct dial around the world (for free)!

You should now repeat this process on your Asterisk servers in London and Tokyo. For brevity's sake, I will give abridged versions of the preceding instructions for the Tokyo and London offices.

For Tokyo, edit /etc/asterisk/extensions.conf and add the following to your internal context:

 exten => _81XX,1,Dial(IAX2/guest@chicago.twidgets.com/${EXTEN},20) exten => _81XX,2,Congestion exten => _83XX,1,Dial(IAX2/guest@london.twidgets.com/${EXTEN},20) exten => _83XX,2,Congestion 

Save extensions.conf and reload Asterisk with asterisk -rx reload.

For London, open /etc/asterisk/extensions.conf and add the following to your internal context:

 exten => _81XX,1,Dial(IAX2/guest@chicago.twidgets.com/${EXTEN},20) exten => _81XX,2,Congestion exten => _82XX,1,Dial(IAX2/guest@tokyo.twidgets.com/${EXTEN},20) exten => _82XX,2,Congestion 

Save extensions.conf and reload Asterisk with asterisk -rx reload.

Hopefully, after this hack, you have realized that with four lines of configuration on three Linux boxes around the world, Asterisk can revolutionize the way your organization communicates. What would have been incredibly difficult and expensive to do just a few years ago has now been reduced to a few pages in a book. It's truly amazing!

Kristian Kielhofner

VoIP Hacks
VoIP Hacks: Tips & Tools for Internet Telephony
ISBN: 0596101333
EAN: 2147483647
Year: 2005
Pages: 156

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net