I have created a configuration profile to add our VPN settings but for the life or me, I cannot find a way to add two DNS servers and a custom search domain to this. Any Ideas? Also, we have a remote office and often with Yosemite, when using ethernet, it does not auto populate the DNS servers and the same search domain there either. Needless to say it has a different IP range so when any computer is plugged into any ethernet cable, it loses the DNS + search domains needed.
This then means I have to WALK alllllll the way over there and set it up 😞
Any help on this would be greatly appreciated and also save me wearing out my shoes!
I've got a script for setting up DNS search domains on Ethernet interfaces available from here:
It could likely be adapted to also provide DNS server settings.
I used this script today and I see it's working for ethernet interface but not for Wi-Fi. Is that how it's supposed to work? I guess I could see an issue with Wi-Fi if it pulls from different wi-fi organizations (work, home. restaurant, etc) and no Locations were set except the default. Just want to check and make sure.
@jonathanla I made this tweak to Rich's script so that it works on Wi-Fi as well as a few different network interface names that are in use by our client machines. You would need to change line 31 of the script to something like this:
ethernet_interface=($(networksetup -listallnetworkservices | awk '/Ethernet/ || /Corp/ || /Wi-Fi/ || /CORP/'))
Thanks for these. Very helpful, but I didn't understand if there's a place in this script, or the others posted from JAMF (id=14892 and id=801). Once these search paths are entered, are they hardware based, or also location based? Meaning the Wi-Fi Search path in the office is different when at home or traveling and I don't want those search paths on those locations, but only Wi-Fi at our work location.
Any clarification would be appreciated.
In our company, we decided to go with DHCP option 119 : this way, when a Mac connects to the LAN, you get immediately the list of search suffixes that are valid/useful for the office where you are currently physically located.
So when people travel and connect to our LAN in another country for example, they immediately get the correct local list of suffixes for that country. This solution works well for Macs, as well as for iOS devices, and works obviously even if the devices are not enrolled. It requires the network team to maintain a different list for every "DHCP subnet group", but once done you are good.
Sure, you cannot do much when people are at home, but at home you probably do not need these search suffixes (if you do, then use FQDNs :-). )
I have found that sending the command with more than 3 search domains creates search domans with quotes around them "xxx" on each domain after the 3rd. How would one prevent this?
sudo networksetup -setsearchdomains "Ethernet" "xxxxx.net" "xxxxx.com" "xxxxx.edu" "xxxxx.edu" "xxxxx.edu"
xxxxx.net xxxxx.com xxxxx.edu "xxxxx.edu"
networksetup -setsearchdomains Ethernet xxx.edu xxx.edu xxxx.edu x.edu xxx.com xxx.edu