How to connect two Asterisk PBXs using a SIP Peer/User Trunk Pairing
Session Initiation Protocol (SIP)) is a signalling protocol used for setting up and tearing down Voice over Internet Protocol (VOIP) calls. A SIP call uses two protocols: SIP and RTP. Real Time Protocol (RTP) is used for the transfer of the actual voice data. If you want to find out more about SIP visit Wikipedia's SIP page.
The first step in setting up an SIP trunk is to draw a picture of what you need to do. Here's an example of a simple PBX to PBX connection that will be using a User/Peer pairing to form a SIP trunk. The two PBXs are name 106 and 111 after their IP host address. They could very well be named Montreal and New York. PBX 106 has all their extensions starting with 3xxx while PBX 111 has all of their extensions starting with 2xxx. This will be handy when making outbound routes.

The SIP trunks are drawn as arrows pointing to their PBX peer and named based on their destination which seems like a good practise. 111-Peer is going from PBX 106 to PBX 111 and 106-Peer is going from PBX 111 to PBX 106. I've left an area on both sides for configuration information.
Note: It is good practise to indicate the protocol used in the naming of trunks, users and peers (ex. 106-SIPpeer). This is very important if you are using multiple protocols for trunking (IAX, SIP and T1). Adding the protocol to the trunk names will create a unique entry and prevent unintentional confusion in the dialplans between trunking protocols!
On the PBX 106 side, I will need to configure an outbound trunk called 111-peer which will connect to the opposite PBX using the account 106-user. PBX 111 will need to create a user account called 106-user on the inbound trunk.
It makes sense to call the user account 106-user because that's who is going to register to PBX 111.
Additionally, on PBX 106, we will need an user account called 111-user so that PBX 111's outbound trunk 106-peer can register to. On PBX 111's outbound trunk 106-peer, we tell it to use user 111-user.
The trunk names and usernames can be called anything you like. I tried to use names that would help explain what is happening.
I've made up a SIP trunk using Peer/User pairing configuration tool in an Excel spreadsheet that creates both PBX 106 and PBX 111's trunk configuration. It is easy and fast to do and takes all the guess work out of it. You enter in the IP address (or domain name) of each PBX, the names for the two trunks, the names for the two users and the user passwords. It spits out the configurations for both PBXs in the same format that you see in the FreePBX Add Trunk menu.
The following pages go through the steps to configure the PBXs using the FreePBX interface. We will configure the trunks one side at a time starting with PBX 106. Once both PBXs have their SIP trunks up, we will configure the outbound routes.
- Configuring the SIP Trunks
- Configuring PBX 106 SIP Trunk
- Configuring PBX 111 SIP Trunk
- Testing the SIP trunks
- Configuring the Outbound Routes
We will be configuring the outbound route for dialing directly to the extension of the peer PBX.
- Now you should be able to dial through each PBX to its peer from any SIP, IAX2 or POTS extension. You can check the status of the phones online and trunks online through FreePBX Statistics window

In creating the trunks, there was no limit put on the maximum number of channels that can use the trunk. For the above FreePBX Statistics window, I had 4 phones (channels) connected in 2 connections (external calls) across the SIP trunk. There are two IP trunks shown here as one is an IAX2 trunk and the other the newly created SIP trunk.
Two channels were IP phones, one was an IAX2 S100i POTS to IAX2 adapter and one FXS pots phone. All worked beautifully! You don't have to configure any protocol translations - the PBX does it all for you.
|