8

On my Mac, I am trying to set my DNS servers so that they are 8.8.8.8 and 8.8.4.4 at my house, while at school they are the router default (they block google's public DNS)

How can I set up my DNS servers to be configured differently for each wireless network?

note: router configuration at my home is not an option.

I am running:
macOS 10.12.3 16D32 Sierra
MacBook Pro 13" w/ 4 Thunderbolt 3

  • This is not directly an answer to your question, but since you mention specifically that you want this because it's blocking Google's, I imagine it might be useful to mention some alternatives. Cloudflare runs a super-fast DNS service at 1.1.1.1 and 1.0.0.1 and OpenDNS offers theirs at 208.67.222.222 and 208.67.220.220. Further reading: 1.1.1.1 and opendns.com – Nate Jun 7 at 16:38
13

How can I set up my DNS servers to be configured differently for each wireless network?

Set and Change in Network Preferences

You can set your own custom DNS settings on a location basis by defining a "Location" in Network Preferences

enter image description here

You would then enter your preferred DNS settings (click "Advanced") under the DNS tab:

enter image description here

After you create set the configuration to your liking, you can call it up by returning to this preferences page and just selecting the location of your choice.

Or...

You can switch from the directly from Apple Menu (). Just choose "Location" and select the location you want

enter image description here

Switch using command Line

For a quicker way, you can switch using the command networksetup. So, to switch to a profile you have already created called "School" your command would be:

networksetup -switchlocation School

Bonus footage...

You could create small bash scripts with the command pre populated and placed (or linked) on your desktop.

#!/bin/bash
#Script to set the location to School

networksetup -switchlocation School
exit

Name it something meaningful like school.sh or school.command (or even just school). Make it executable by issuing the command chmod +x /path/to/school.command (or whatever you called it). Make another for Home, Work, In-Laws, or wherever. When you double click on it, it will change the network location and your preset settings.

Caveat

If your organization (like your school) blocks outside DNS servers and traffic limiting it to the DNS servers they specify, you won't be able to override them.

  • Great, thanks! I actually was using this because I discovered Google DNS is blocked by the school, and I need to use Google DNS at home without router config. Works like a charm! – Jackson1442 Mar 22 '17 at 23:20
  • On MacOS mojave, the sub command should be -switchtolocation; $ networksetup | grep switch Usage: networksetup -switchtolocation <location name> – Tai Le Dec 27 '18 at 4:11
0

I have posted on my Github a script as a solution to this problem. If you are interested you can use it. https://github.com/andreabac3/CDDN-Change-DNS-Dynamically-with-your-Network

  • 1
    Instead of posting a link to a script therefore sending people offsite and without an explanation how the script solves the problem please add the essential parts of the script directly into your answer and explain how it works. You can still leave the link in for people looking for the full solution. – nohillside Jun 2 at 11:19
  • @nohillside Sorry, you have right, I made an assumption the explanation of how it works is in the README attached with the script. I will modify my answer. Thank you for suggestions. – Andrea B Jun 10 at 8:28
-1

You can also install dnscrypt so that the curious people that run the school don't know to which sites you are navigating.....

  • This isn't really an answer, it's more of a comment. – fsb Feb 23 at 15:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .