2x FreePBX systems 1 as PBX and 1 as gateway

I am trying to improve a setup which I inherited where I have several FreePBX systems running as office style PBX’s with extensions attached and trunks that all point to a single FreePBX box acting as the gateway for all calls in and out (sits between PBXs and SIP providers).

The current setup has a SIP trunk on both sides but on the gateway, outbound calls are caught in the Inbound Routes by the caller-id set on the PBX’s. This causes all kinds of issues I guess I don’t need to go into but the biggest is that I can’t use “Outbound Routes”.

There are reasons why it was setup this way I suppose but, I want to Undo this. I would like calls that come in from the PBXs to flow into the outbound routes just like an extension.

So, I thought Hmmmm… Let me remove the trunk for the PBX and setup it up as an extension instead (on the gateway side) and leave it as a trunk on the PBX side.

This seems to accomplish most of what I need except, when the calls come in to the gateway and I route them to the PBX through Inbound Route > Extension (on PBX), the calls show up on the PBX side with DNIS/DID attached. This means the calls fail on the PBX unless I set an ANY/ANY inbound route which is not ideal.

I can’t figure out for the life of me why the DNIS info is missing when the inbound call is passed from the gateway FreePBX to the PBX (also FreePBX). When phones are connected as extensions, they pass the info fine.

Guess I just go lost somewhere. Any help would be appreciated, please let me know if you need any further info.

Aside from my current situation described above, does anyone have suggestions on the best way to use multiple FreePBX boxes all sending/receiving external calls through a single FreePBX used as a gateway between the SIP providers?

I can’t use IAX, it’s not an option.

We are Asterisk people here, may a ask why you can’t use IAX?

The main reason is that we already have one Non Asterisk SIP only PBX that uses our gateway currently and we are likely to have a few more in the near future.

Also, they are just trunks either way so I am not sure it would matter if it’s SIP or IAX.

Personally I don’t want to use FreePBX as the gateway at all but I am just tying to improve what I have as step one. Step two will be to remove FreePBX as the gateway and replace with vanilla Asterisk which I am much more familiar with.

You could perhaps take that logic a step further and replace the “gateway” box with a real SIP proxy, Asterisk, with or without FreePBX, is just not designed for that task, it will solve your current problem and leave everything doing what they were designed for.

I agree Dicko, for now though I am trying to get to a better place with the pieces I have to work with.

Vanilla Asterisk is just what I know and prefer it in the short term for that reason.

For now, if I can figure out why the dialed number is getting lost from the gateway box to the PBX box, I would be in a whole lot better place. Any ideas?

Then surely you can just use asterisk in it’s pure form and with all its B2BUA restrictions without FreePBX, not so? As to what is getting lost , just add any noops and dumpchan() as necessary to your dialplan and explore /var/log/asterisk/your_custom_logs as appropriate, but FreePBX is pretty good at stating what it is doing in /var/log/asterisk/full

Some tricks that you can do, set up the trunks as intracompany routes and if you change the trunk context from context=from-trunk to context=from-internal then the trunk switches from following inbound rules to outbound rules. One other thing, you really haven’t provided any information on your configuration except to say you have a problem.