Macs and local DNSMasq – clients keep forgetting results given by local DNS

dnsNetworkosx-server

I have a number of Mac OS X El Capitan and macOS Sierra clients whose DHCP configurations give them the local IP address of a DD-WRT router with DNSMasq setup within my LAN.

This is so I can use server.example.com and have it go to 192.168.1.3 and not our public IP address, and is far easier to manage than editing the hosts file of every mac, and also doesn't affect portable Macs when they need to connect to the same hostname from outside the building.

However, repeatedly some Macs keep 'forgetting' the local DNS. For example, when the problem occurs, I can ping the server hostname and get the external public IP. I can then clear the DNS cache, run the ping again and it's now the correct local IP address.

Does anyone run a similar setup, and know of any common pitfalls or issues, and how to get around them?

Prior to using DNSMasq on a DD-WRT router, I was using the Mac OS X Server App's DNS ability, but found it to be very slow as the same server was running File Sharing for the studio, so it was moved off.

I have even thought about running a scheduled command (either on each Mac, or via some Remote Desktop Management script) to clear the DNS every few hours or so.

Best Answer

Yes - this has been a pain for a long time and many generations of networking hardware and software.

Personally, I've given up on running my own dns and now pick one of two items.

  1. Use mDNS and host.local for resolution and let DHCP assign addresses from a pool.
  2. Set DHCP reservations for each device I care to connect to and use http://xip.io to resolve that IP by name.

In your case, I use 192.168.1.3.xip.io in place of server.example.com where I need to put a FQDN in for resolving a server name. I've never had this be unstable, but if you do, there are other providers like http://nip.io do the same service.