Freeswitch as B2BUA between FreePBX and SIP trunking

I am trying to get my head around how to build out a Freeswitch box to sit between several FreePBX on-prem servers and a couple of SIP providers. Freeswitch will act as a B2BUA and provide call routing and fail-over.

I am having a mental block about how to think about the different elements here. I am stuck in the conceptual framework of a simple PBX/Trunk scenario and Freeswitch is generally geared towards a PBX concept also. But I know it is certainly capable of fulfilling the role I am looking for.

In my scenario - we have a Public and Private profile with the SIP providers on the Public side and the FreePBX boxes on the Private side - so far so good. The SIP providers are clearly gateways where we receive and route calls to/from the PSTN. But, are the FreePBX servers Extensions? Is an “Extension” just an endpoint for SIP UACs to register? That is where is all gets messy. It seems that I need a gateway that is also a registrar?

What are you trying to accomplish with the design? The most common use is to aggregate carriers so you only have a single trunk to set up to each FreePBX as in the image below. In that design, you will create SIP trunks between each carrier and FreeSwitch. Then you will create a SIP trunk between FreeSwitch and each FreePBX instance. The challenge in this design is that FreeSwitch will need to know to where to send each inbound and outbound call.

For example 111.111.1111 may come from Carrier 1 > FreeSwitch > FreePBX 1

and 222.222.2222 may go Carrier 4 > FreeSwitch > FreePBX 2

The easiest way around this is to provision DIDs via API. That way you could configure the route on FreePBX, FreeSwitch, and the carrier at the same time. There are no pre-existing services to do this. You would need to build this yourself. But this is very similar to how hosted providers like me build our networks. Just 10 or 15 times more complex, and with different software. Hope this helps.

1 Like

Ray,

You are spot on with your design - what I am looking to accomplish to have a little something between the tier 1 carriers and the customer PBX for inbound DID routing, outbound fail-over, e911, etc. What I am looking for is what I like to refer to as an “NSS” - Non-Scalable Solution - which means, I need it to be robust and technically functional, but I do not need it to scale. The number of new customers we add is small enough where we can manually set up the DID and routing and the efficiency gained by building out a more automated process probably would not be cost effective - at least for now - and the call volume is low enough that I can just stand up a new cloud instance as needed to distribute load. Once I have the the core functionality I want working, I think I can create a working FusionPBX interface that would give us a nice GUI front-end for setting up the routing and fail-over, etc. without having to be on the command line.

I have been getting my head back around Freeswitch and what the configs look like in this type of SBC implementation. I don’t believe there is really a technical distinction between a “Trunk” and an “Extension” (which I was having a mental block on) - you just have SIP profiles listening on certain ports and routing based on your dialplan. I think for my needs - it makes sense to keep the default “External” and “Internal” type of profiles - where the External profile is talking to carriers and Internal has customer facing FreePBX servers - but I am still working through that.

Appreciate your feedback very much.

I think that dSIP Router is a perfect fit for your needs. (Carriers → dSIP Router → PBX Servers)

@PitzKey - great solution! Thanks for that.

1 Like