Interconnecting two FreePBX machines with SIP Trunks and Caller ID


I have searched quite a bit on this subject over the past couple of weeks and not sure if I am completely off track or not.

Basically this is the setup we have.

Machine 1 - FreePBX Installed handles a trunk connected to a SIP provider and has incoming routes for various DID’s

Machine 2 - FreePBX Installed has no direct trunks coming in so I want to setup a interPBX trunk first and then try to route certain DID’s to this machine.

On both ends I have a similar trunk config.

Machine 1 has a regular trunk and is able to get inbound calls properly and has caller ID on the incoming side.
Machine 1 has a interconnect with Machine 2 on a trunk called machine1-machine2
Machine 1 also has an extension setup to handle trunk calls (not sure if I am doing this wrong)

Outgoing Settings
Trunk Name; machine2-peer
Peer Details
host=ipaddress of machine 2
username=xxxx ’ (extension on machine 1) - Lets say for example this is 9992
fromuser=xxxx ’ (same as above extension)

Incoming Settings
Trunk Name: machine1-peer

Machine 2 has the exact same settings as above, but with the trunk names reversed and changed accordingly and an extension on that side.

Outgoing Settings
Trunk Name; machine1-peer
Peer Details
host=ipaddress of machine 1
username=xxxx ’ (extension on machine 2) - Lets say for example this is 3333
fromuser=xxxx ’ (same as above extension)

Incoming Settings
Trunk Name: machine2-peer

I also have an outbound route on both sides to dial extensions on each others sides…so both machines can reach each others set of extensions.

Everything works here and I can dial extensions on machine 1 from machine 2’s extensions without an issue and so on. However every time machine 1 dials machine 2 the caller ID is always 9992 (whatever extension I set above on machine 1).

I have an incoming route for the DID in question getting routed to a Ring group (This is the only way I could make an inbound call get routed to an extension on the other side).

Is there any way I can generate a diversion header to work for the caller ID? - I have the latest build of freepbx where I can navigate to Setup->Advanced Settings->Generate Diversion Headers and set it to true.

I would like to see Machine 2 get caller ID from the inbound route on Machine 1. Is this even possible with this config? or am I doing this totally wrong?

Thanks for your help.

No - you need to scrap all of that confusing config.

You don’t need incoming settings because the information is the same in and out.

Also, the context needs to be from-internal so the two systems can reach each others dial plans.

Make sure the routes have the inter company option selected.

IAX trunks are also easier than SIP.

Hey SkyKingOH,

Thanks for your response, that actually got a bit more working.

I deleted incoming settings on both ends and just setup a type=friend following this page…

So far callerID seems to work, however machine 2 cannot dial out now as I am getting a call cannot be completed signal

All I have now are the outgoing settings on both end resembling this…

host=xxxx (ip of the other machine)

Machine 1 and Machine 2 can now both reach each other and caller ID seems to be working fine, however machine 2 tries to dial out using a trunk on machine 1 (only outbound sip trunk) now gets a call denied. Same thing I would get if I don’t set the callerID going out.


You must have a route wrong. You need to send any trunk codes needed for the outbound call.

We can’t tell anything from messages, you need to post full configs and logs.

we’ve covered this several times in the last month or so. Here’s what I wrote the last time:

This issue is covered pretty well in the “… without tears” series of guides. The most current is Elastix Without Tears, which you can download here:

Although this refers to Elastix, Elastix uses FreePBX. The configuration is identical. Look at page 153, which explains how you can set-up an IAX2 trunk to route calls between two locations.

Basically, you just need to set-up the internal trunks and then set up an outbound route that will route calls to the internal trunk. The “…without tears” book will tell you how to set-up the outbound route to send calls to extension over the internet, but you can add another routing that lets you dial standard calls and have them routed. My preference is to allow users to dial a prefix, i.e. 81, and then the number, to force it to go over a specific trunk.

So, you’re outbound route could be:


The first line would allow any calls to extensions 60 to 69 to go over the internal trunk. The second line would allow any calls to 81 plus 1, area code, and number, to go over the trunk, but would strip the 81 off before sending it over. As long as the trunk is setup correctly (i.e. context=from-internal) per the Elastix Without Tears book, the remote system will receive the call and process it in the same way is if a local user picked up the phone and dialed that same number.