Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

C3453246L

macrumors newbie
Original poster
Jul 15, 2024
3
1
Florida
I have a complicated DNS question on Mac Sonoma 14.5.

I have 2 DNS servers a primary and secondary. My primary DNS server is a DNS server that I host myself using Bind9 on a Linux server and my secondary is from my ISP.

If I reboot my primary DNS server (the one I host using Bind9) - my Mac automatically switches to my secondary, like it should.

When does the Mac go back to using the primary server?

I tried restarting the ethernet connection from the CLI (using sudo ifconfig en0 down and up), but that doesn't work.

the only way I can get it back to using the primary is if I unplug the ethernet cable from my Mac mini and plug it back in.

Is there a timer that Mac OS uses before it tries the primary DNS server again? I thought maybe it was the IP lease time, but I have an Eero router and can't set the lease time. I can try a static IP address but dont think it would work either.

Who knows how Mac determines when to switch back to primary DNS server and have to automate it.

Eventually my goal is to setup a cron job if I know the CLI command to force it back to my primary DNS rather than ISP's secondary server. I'm using my own DNS server for privacy and speed.
 
No need for sudo, use networksetup

Code:
networksetup -setdnsservers Ethernet Empty

networksetup -setdnsservers Ethernet primaryDNS secondaryDNS

Example with public DNS servers

Code:
networksetup -setdnsservers Ethernet 8.8.8.8 1.1.1.1

To turn Ethernet off/on

Code:
networksetup -setnetworkserviceenabled Ethernet off

networksetup -setnetworkserviceenabled Ethernet on
 
  • Like
Reactions: Slartibart
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.