SIP Trunk Registration issues with FusionSIP

Hello,
I have been using FreePBX for our company for almost 3 years and have been having an intermittent issue with our trunk registration to FusionSIP (formerly BroadVox). I finally found an issue linked to DNSMASQ and wanted to pass on the info to anyone else who might be having the same issue and find out if there is something else I am missing.

Here is what has been happening.
Original Trunk Config
Outgoing:
type=peer
canreinvite=no
host=nd01-03.fs.fusionconnect.net
username=PTN
secret=secret
insecure=port,invite
qualify=yes
disallow=all
allow=ulaw&alaw

Incoming:
secret=secret
type=user
context=from-trunk

Register String: PTN:secret@nd01-03.fs.fusionconnect.net/PTN

Our trunk would connect and come up without an issue and all would be fine for anywhere from 5 minutes to 2+weeks. Then suddenly we could not receive calls, and any outbound call came back with the congestion message “All Circuits are Busy.”

SIP reload would sometimes fix it for another 2 weeks sometimes it would fail again in 5 minutes. Rebooting the entire server would usually fix it for more than 2+ weeks. But the issue kept creeping up.

With packet captures on both my end and fusion’s we determined that FreePBX would register to the primary server IP using the 90 second interval and then randomly change to the secondary IP. This was causing an error on their end as their servers would have to re-map registrations and we would get an “Unauthorized” response then try again and connect. FreePBX was bouncing back and forth sometimes every registration interval. The process would end up restricting our account for 180seconds for security reasons. So unitil there was a 180sec pause in attempts our trunk would not authenticate.They recommended listing the direct IP addresses in order of preference to stop this. Which was tried but was having the same issue within days. I then changed the trunk config to use the primary only.

NEW Trunk Config:
Outgoing:
type=peer
canreinvite=no
host=64.190.232.6
username=PTN
secret=secret
insecure=port,invite
qualify=yes
disallow=all
allow=ulaw&alaw

Incoming:
secret=secret
type=user
context=from-trunk

Register String: PTN:secret@nd01-03.fs.fusionconnect.net/PTN

This seemed to have solved the issue. Our trunk was registering to the primary server only and was up without issue for almost a month. The downside there is no automatic failover to the secondary server if the primary is offline but I could deal with that.

Last week our trunk started dropping again. I thought is was an issue with our ISP, as we have all kinds of quality issues with them and more drops than a microphone at a rap concert, but the connection was only responsible for the first two dropouts. In doing a packed capture and SIP debug on the trunk I found that the same thing was happening again, the trunk was trying to register randomly to the second server. It would even do this while there was an active call on the primary server where the call would then go one way audio as it was receiving from the primary but trying to send to the secondary. Then the call would just drop. I checked the trunk config and nothing had changed. I had no idea where it was getting the second address from.

I then did a DIG on the FQDN of the servers and found the localhost DNSMASQ had cached both addresses. Which is why it works for a while after a reboot as the cache is cleared. All I can figure is it looked up the address based on the register string as that is the only place the FQDN is listed. Why it is doing this I don’t understand. So I went to the /etc/hosts file and added the primary server IP to FQDN. Hopefully this will keep it on the correct server.

I would like to figure out a way to have it automatically fail over, but right now I just want the trunk to stay up.

FreePBX 13.0.192.16

Thanks

nd01-03.fs.fusionconnect.net probably comes back with a couple of addresses, right?

Also, try this:

PEER Settings::
type=friend
canreinvite=no
host=64.190.232.6
username=PTN
secret=secret
insecure=port,invite
qualify=yes
disallow=all
allow=ulaw
context=from-trunk

Leave the Incoming (User) config blank.

Also, your registration string needs to be set up for the specific IP address you are using. As to the “automatic failover”, just set up two trunks, one for each IP address. That way, you can specify which trunk you want to use for your outgoing connections and the system will fail over to the one that’s working automatically.

Yes this comes back with both primary and secondary addresses.

I changed my trunk setup to your suggestion and everything is working except:

The trunk does not authenticated with the IP address in the register string, only the @nd01-03.fs.fusionconnect.net works. If I put the IP the response is “Unauthorized” on each attempt. I am guessing this register string is where the differing IP address was getting pulled from even though I had the address hard coded into the SIP host line.

Making 2 trunk routes would solve the issue but I can only register to one at a time because of the above. If I have 2 trunks the first one registers correctly, but as soon as the second one registers the first one is dropped by Fusion. Then trunk 1 re-registers and it becomes a viscous cycle.