{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/network-specific-dns-settings-on-macos","result":{"data":{"allGhostPost":{"edges":[{"node":{"title":"Network-specific DNS settings on macOS","html":"

Cloudflare recently announced 1.1.1.1, their new privacy-first super-fast DNS resolver. I updated my LAN DNS resolver to use 1.1.1.1 in place of 8.8.8.8 as the upstream DNS server, but I also wanted to apply these settings to all networks, not just my home network.

\n

One option would be changing macOS's DNS settings to use 1.1.1.1 instead of whatever the DHCP server pushes to it, but that would also mean that I would lose the advantages of running a LAN DNS server—mainly being able to access local machines using their hostname.

\n

I created two macOS network locations. One called Home that kept the DNS settings empty and therefore wouldn't override the current network's defaults, and one called Not Home that has 1.1.1.1 and 1.0.0.1 hardcoded as the DNS resolvers.

\n
\"screenshot\"
\n

Now, I can go into System Preferences and choose a network location and automatically have my DNS settings set to either Cloudflare's or the current network's defaults.

\n

I use ControlPlane to automate switching between the two locations, depending on the WiFi network I'm connected to. With ControlPlane, I can create "contexts" and "rules" for when each context is applicable based on "evidence sources." Then, I can configure "actions" that are run when a context is activated or deactivated.

\n

I created two contexts, named Home and Not Home like the network locations, and two corresponding rules based on my home WiFi network's BSSID using the Nearby WiFi Network evidence rule. It says "Nearby" but it's only activated when you're actually connected to the network.

\n
\"screenshot\"
\n

Finally, I created two actions to switch to right network location depending on the context:

\n
\"screenshot\"
\n

And that's it! macOS now uses 1.1.1.1 on public networks, and my local DNS resolver at home.

\n","published_at":"2018-04-10T20:49:41.000+03:00","slug":"network-specific-dns-settings-on-macos","tags":[],"plaintext":"Cloudflare recently announced 1.1.1.1\n[https://blog.cloudflare.com/announcing-1111/], their new privacy-first\nsuper-fast DNS resolver. I updated my LAN DNS resolver to use 1.1.1.1 in place\nof 8.8.8.8 as the upstream DNS server, but I also wanted to apply these settings\nto all networks, not just my home network.\n\nOne option would be changing macOS's DNS settings to use 1.1.1.1 instead of\nwhatever the DHCP server pushes to it, but that would also mean that I would\nlose the advantages of running a LAN DNS server—mainly being able to access\nlocal machines using their hostname.\n\nI created two macOS network locations [https://support.apple.com/en-us/HT202480]\n. One called Home that kept the DNS settings empty and therefore wouldn't\noverride the current network's defaults, and one called Not Home that has \n1.1.1.1 and 1.0.0.1 hardcoded as the DNS resolvers.\n\nNow, I can go into System Preferences and choose a network location and\nautomatically have my DNS settings set to either Cloudflare's or the current\nnetwork's defaults.\n\nI use ControlPlane [https://www.controlplaneapp.com/] to automate switching\nbetween the two locations, depending on the WiFi network I'm connected to. With\nControlPlane, I can create \"contexts\" and \"rules\" for when each context is\napplicable based on \"evidence sources.\" Then, I can configure \"actions\" that are\nrun when a context is activated or deactivated.\n\nI created two contexts, named Home and Not Home like the network locations,\nand two corresponding rules based on my home WiFi network's BSSID using the\nNearby WiFi Network evidence rule. It says \"Nearby\" but it's only activated when\nyou're actually connected to the network.\n\nFinally, I created two actions to switch to right network location depending on\nthe context:\n\nAnd that's it! macOS now uses 1.1.1.1 on public networks, and my local DNS\nresolver at home.","meta_description":null}}]}},"pageContext":{"slug":"network-specific-dns-settings-on-macos","prev":"to-do-lists-simplicity-is-key","next":"fresh-coffee-aeropress"}},"staticQueryHashes":["3649515864"]}