Local DNS not updating after wan IP change and DDNS

I have a custom DDNS that I use on several routers that works fine. On one router though, when the IP changes (happens every reboot of the router) the DNS host record is changed, I can use another machine outside the LAN and the change is seen, but if I log onto the router or any machine on the LAN and ping the DDNS domain, it is still the old IP.

I have found that if I modify the DNS server IP for the WAN interface and apply changes, regardless of what the new DNS server is, when I then ping the hostname it is the right IP.

Is there a way to refresh local DNS on the router? I tried just restarting dnsmasq but that doesn't work.

It should update when TTL expired and next query is made.

If this isn't working, you nay need to adjust TTL.

2 Likes

So I'm not sure where I'm going to change TTL. Can you tell me where that would be?

This would be set at the hosting company that handles of your domain name (i.e. DNS Server). For DDNS (and other purposes), it's commonly set to 300 seconds.

Ahh... Ok, so, as I pointed out, from outside of my local network I can access the router via the ddns hostname so the problem is only the LAN side. It seems to be DNS caching, but restarting dnsmasq doesn't resolve it..

1 Like

There are multiple possible DNS caches: browser, localhost, router, upstream gateway, ISP.
Some of those may involve DNS hijacking, which you can bypass with VPN or DNS encryption.

1 Like

This is specifically on the router. If I do a ping hostname.ddnsserver.com from ssh on the router, it's the wrong ip.

  • Is it always the same wrong IP - or different ones?
  • And is this IP Public or Private?

How did you restart dnsmasq?

From https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html#lbAG:

When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-hostsdir, --dhcp-optsfile, --dhcp-optsdir, --addn-hosts or --hostsdir. The DHCP lease change script is called for all existing DHCP leases. If --no-poll is set SIGHUP also re-reads /etc/resolv.conf. SIGHUP does NOT re-read the configuration file.

Stays the same as before boot. Public IP

What is the correct cli way to restart dnsmasq so it will clear cache?

killall -HUP dnsmasq

That didn't make any difference. So to summarize:

I reboot and the router comes up with a new IP:

#1 - Ddns is working. I can immediately go on my phone using GSM, I can connect to the router on the new IP.

#2 - On the router, the IP4 upstream IP is correct.

#3 - SSH into the router and nslookup shows the old IP address still.

root@router:~# nslookup home.xxxxxxxxx.xxx

Server: 127.0.0.1
Address: 127.0.0.1:53

Non-authoritative answer:
Name: home.xxxxxxxxx.xxx
Address: xxx.xxx.xxx.xxx <- old address
Non-authoritative answer:

#4
killall -HUP dnsmasq
nslookup is still the same old address.

This indicates the cause of the issue is related to your upstream DNS provider.