I am working on building a hosted PBX platform and am testing an architecture where FreePBX is placed behind Kamailio acting as the SIP registrar and edge proxy.
• Phones register successfully to Kamailio
• Kamailio authenticates against a MySQL subscriber database
• Phone-to-phone calling works through Kamailio
• Kamailio to FreePBX SIP trunk is functioning
• FreePBX to Kamailio trunk is functioning
• RTP audio flows correctly
• Outbound PSTN calls from FreePBX work
What Is Not Working
FreePBX does not see device registration or contact state because endpoints register only to Kamailio.
Because of this:
• Ring groups fail
• IVR routing to extensions fails
• Extension dialing from FreePBX features fails
• FreePBX attempts to dial local endpoints instead of routing calls back through Kamailio
We have attempted several approaches including dialplan overrides and static contact routing, but they have not produced a clean or scalable solution.
Question
Is running FreePBX behind an external registrar like Kamailio a supported or commonly deployed architecture?
Or is the recommended approach to use Kamailio primarily as an SBC/NAT/security layer while still allowing phones to register directly to FreePBX?
Any real-world deployment experience or design guidance would be greatly appreciated.
First, do not use AI to create posts. It’s against the guidelines, someone could flag this as inappropriate.
Second, you need to use the UAC module for passing REGISTERs, INVITEs, SUBSCRIBEs through and you’ll also need to be able to route that traffic back and forth.
Or you can just proxy everything through straight to the PBX and not do the REGISTRATIONs on the Kamailio box. That is going to be up to your own design and needs.
My apologies on using AI. I use it to track technical aspects of a project to create documentation later on. Helps me stay on point. My memory isn’t what it used to be:). I use it as a tool, maybe I lean on it too much. No harm meant and I will not let it happen again.
So, you mean to proxy through Kamailio to the PBXs? Or, remove Kamailio, which is not easy to configure, by me anyway. Basically, I have Kamailio and RTPengine working flawlessly. It is when FreePBX is put in the mix that disaster happens. I went so far as to create a DB server to house the SIP credentials and synced to FreePBX. I had some success there, but the ring groups failed. I should have seen that coming but was lost in the weeds. I think I feel too invested in the work I have put in. So I’m looking for a fresh perspective from someone that has either done this or knows how. I don’t mind doing the work, just need the right tools. Think I may have made some wrong choices in my original design. Thoughts?
I looked at the dsiprouter site. It seems like they are saying that they basically support one FreePBX server, unless clustered. That gets me back to using a trunk and the same problem I have now, which is ring groups not working through it. Am I seeing this correctly? I’d love for dsiprouter to be the answer. I had not considered it before. Thank you for pointing it out and let me know if I am not correct.
That’s definitely not correct about supporting one instance of FreePBX. Where did you read that? I’ve supported multiple instances of FreePBX behind a single Dsiprouter instance
I owe another apology. Helps if I read the whole paragraph. Mind giving me a quick design of your setup? Do you have the ability to use ring groups, IVR, etc in your setup?
“Here we will demostrate how to setup dSIPRouter to enable hosting FreePBX using Pass Thru Authentication. FreePBX is designed to be a single tenant system or in other words, it was built to handle one SIP Domain. So, we use dSIPRouter to define a SIP Domain and we pass thru Registration info to the FreePBX server so that you don’t have to change how authentication is done. However, this will only work for one FreePBX server. If you have a cluster of FreePBX servers then use “Local Subscriber Table” authentication. The value of having dSIPRouter in front of FreePBX is to provide you with flexibility. After setting this up you will have the ability upgrade or migrate users from one FreePBX instance to another without having to take an outage. The following video shows how to configure this. The steps to implement this is below the video.”
It says it there. You have one Dsiprouter domain per FreePBX instance. Are you proxying phone registrations as well? Or just SIP Trunking? And yes I have all the FreePBX functionality working behind the dsip instance
I see that now. I will create DNS Cust1.PBXHOSTDOMAIN.com, Cust2.PBXHOSTDOMAIN.com, etc. I missed “domain”, my fault. My hope is to allow FreePBX to do its own registration per customer. I assume it will pass through dsip as it did with Kamailio?
That is one of the issues. And as this is a test environment, I am looking for the “correct” way. I am standing up a new VM with linux/dsiprouter now for testing. My issue has been connecting FreePBX behind Kamailio and all feature still working. The phones will be connecting to the external facing SIP server and rerouted to FreePBX via a custom DNS. I have completed that to an extent. The phones could call with no issue and sound passed through RTPengine successfully. I ran into problems with SIP authentication and used a convoluted method to get that to work. All in all, too many moving pieces and a configuration nightmare on a larger scale. So, I am now testing various softwares to see what fits and what complexities can be eliminated. Hope this helps. Any recommendations would be appreciated. And as always, thank you for your help.
you don’t need an actual routeable domain with DNS A record. You’d set the outbound proxy field of your phone to dsip ip or FQDN and set the sip domain on the phone to the domain you created on dsip
I am using FreePBX 17 and I am still working on getting dsip set up. It is fighting me. I am creating another Ubuntu 24.04.4 server for a fresh install. Hopefully that one will go without a hitch. I was thinking of DNS just incase things changed in the future. Easier to move around in my datacenter.
If you are looking to use dsip to proxy registrations and sip trunking, I’d say use FreePBX 16 for now. I’m still trying to get both working with FreePBX 17. Deprecation of chan_sip in FreePBX 17 is causing some issues in dsip based on my lab trials
That is good info. I will stand up a ver 16 for testing. It never occurred to me to try that when I had issues before. “Assumed” 17 would work without issue.
Right and I pointed out that Kamailio doesn’t care or know the difference about what sip driver FreePBX is using. So to imply that with chan_pjsip Dsip (Kamailio) doesn’t work right is just wrong.
You are recommending to use a version of FreePBX that will be EOL soon based on misinformation. FreePBX v17 can run chan_sip as long as you are on Asterisk 20 or lower. As well, chan_pjsip works fine with Kamailio and therefore Dsip so if you’re having issues making it work it most likely a lack of understanding of how chan_pjsip works vs chan_sip.
So wether the OP started with pure Kamailio or DSip, the fact that outbound was working means some how Auth was being sent from Kamailio to Asterisk in some manner or worse, there was no auth and FreePBX/Asterisk is letting anything send outbound calls. Or because the registrar/location is all within Kamailio/Dsip, the extension to extension calling was working because it was being routed through Kamailio and never touching Asterisk.
However, the whole “incoming calls” issue where the PBX can’t send incoming calls to the phones. That is due to the registrar/location services being on Kamailio and not passing said information to the PBX.
This is 100% configuration issues on either one or both Dsip/Kamailio and/or FreePBX/Asterisk. There’s no need to drop back to FreePBX v16 or even chan_sip because that just leaves the OP in a position of completely no support in a years time because everything on the FreePBX part will be EOL.
@jural1 as I said before, you need to pass the information from Kamailio the PBX via the UAC module if you want the locations to stay on Kamailio. I’d watch how you handle the auth because you could end up exposing your FreePBX system(s) to anyone using them if the auth is janky or non-existent because “it made it easier” with Kamailio.
Dsip (as it is) relies on chan_sip to route trunk calls (I believe) and chan_pjsip for extensions (or vice versa). The project lead is aware and has plans to iron that out