Sofia DNS resolution issue

Status
Not open for further replies.

bcmike

Active Member
Jun 7, 2018
326
54
28
53
Hi all,

I just thought I'd post my recent struggle with Sofia and DNS resolution.

First things first I run Freeswitch 1.10.2. I currently give all of my tenants a gateway that goes to an ASTPP box which allows me to keep track of of them individually for billing purposes. Originally all the gateways pointed to the local IP of that ASTPP box and this worked well, however I'm starting to replicate to an off site fail over site and the ASTPP box at the other site has a different local IP, so my solution was going to be to change all the gateways from IP to a host name and then just add an entry to the hosts file on each box to reflect the different ips of the respective ASTPP boxes. Simple right?

So I tested with a dummy domain to begin with (thankfully) . I made my hosts entries and changed the gateway proxy from an IP address to a host name, stopped and started the gateway but no reg. I checked credentials, etc, still nothing. I changed it back to the IP and it reged. I then looked in the logs and found that when I tried to start the gateway with a host name it failed with a "DNS Error [503]" . I could ping the host name no problem, so then I did a little research.

Some people reported that Sofia would usually bypass the hosts file for name resolution and that you needed a proper resolver. Well that's a pain in the butt. So I installed dnsmasq as a local resolver and put the necessary entry in. I did a dig on the host name and everything looked good . Swell right? Nope still no reg. So back to research..

Apparently Sofia will do an initial lookup at some point and cache it but it will not do a lookup for a reg event. Actually some people say they don't see any DNS traffic coming from their freeswitch boxes at all after initial startup (I find that hard to believe though). What I have found is that Sofia has a DNS cache and that cache is seldom purged or updated. What I ended up doing was putting a different host name entry into dnsmasq, and the I created another gateway from scratch with the new host name. That worked!! Adding the new gateway must have forced a lookup!

Anyway, after hours I'm going to see if restating Freeswitch will force a lookup on existing gateways. It's an obscure problem for a specific use case but I thought I'd document it here in case someone runs into the same thing.

I'll update if I find out more.
 

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,388
364
83
Interesting findings @bcmike I'm not surprised, a couple of years ago, I proved with packet captures that our Yealink phones only queried DNS on startup and not when registration/re-registration occurred. The situation may have changed now with later firmware, but at the time it meant that we could not use DNS as a method to facilitate fail over for the UACs.
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,038
556
113
Interesting...

@bcmike Why are you not just creating two gateways per outbound route eg sip1.blah, sip2.blah? Thie is exactly how I have my outbound routes configured and have done so for years, it works perfectly.

@Adrian Fretwell Yealinks work perfectly for me with Route53 records set at 120s for failover.
 

bcmike

Active Member
Jun 7, 2018
326
54
28
53
Interesting...

@bcmike Why are you not just creating two gateways per outbound route eg sip1.blah, sip2.blah? Thie is exactly how I have my outbound routes configured and have done so for years, it works perfectly.

Actually that's a pretty great idea. The Fusion box talks to the ASTPP box on the local subnet but if I define ASTPP_site1 as primary and ASTPP_site2 as secondary if I lose site 1 entirely then the Fusion box at site 2 tries its primary, fails and then uses its secondary which is the local ASTPP_site2. The added bonus (maybe) is that both sites are connected via VPN so if I lose just The ASTPP_site1 box it'll failover to site 2. Hope that makes sense.

The reason I have some added complexity is that one of my design goals was to put everything behind a firewall and have the interbox traffic run locally. I've overcome a lot of NAT BS but I'm honestly starting to re-evaluate that position.
 

bcmike

Active Member
Jun 7, 2018
326
54
28
53
FYI: Restarting Freeswitch will force a DNS lookup on all gateways.
 
Status
Not open for further replies.