
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-05-2012 07:20 AM
I've been tasked with implementing this change on some remote users. I've had a quick scout around and can't see an easy way of doing this. Anyone got any ideas?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-05-2012 07:26 AM
do these hosts use dhcp? if so, add them to your dhcp server config, and you won't need to touch the clients.
if they're assigned static IPs, you can use /usr/sbin/networksetup to do the job. i wouldn't go that route unless it's the only option.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-05-2012 07:26 AM
do these hosts use dhcp? if so, add them to your dhcp server config, and you won't need to touch the clients.
if they're assigned static IPs, you can use /usr/sbin/networksetup to do the job. i wouldn't go that route unless it's the only option.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-05-2012 07:35 AM
Thanks. Makes total sense just need to speak to their comms guy now.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 03-05-2012 09:03 AM
Here is the script I use:
#!/bin/sh
##################################
# Output: Setting Search Domains #
##################################
##################################
# Do Not Modify Below This Line #
##################################
/usr/sbin/networksetup -setsearchdomains "Ethernet" "yourcompany.com" "sub.yourcompany.com"
/usr/sbin/networksetup -setsearchdomains "Ethernet 1" "yourcompany.com" "sub.yourcompany.com"
/usr/sbin/networksetup -setsearchdomains "Ethernet 2" "yourcompany.com" "sub.yourcompany.com"
/usr/sbin/networksetup -setsearchdomains "Airport" "yourcompany.com" "sub.yourcompany.com"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 06-06-2023 04:20 PM
Thank for this - I ended up reworking it for our needs to include DNS servers as well / had to make a minor adjustment for systems with a single Ethernet interface but that was pretty easy once the dual interface systems test proved positive results:
#!/bin/bash
##################################
# Output: Setting Search Domains #
##################################
##################################
# Do Not Modify Below This Line #
##################################
primary_dns="X.X.X.X"
secondary_dns="X.X.X.X"
tertiary_dns="X.X.X.X"
services=("Ethernet 1" "Ethernet 2" "Wi-Fi")
for service in "${services[@]}"; do
/usr/sbin/networksetup -setdnsservers "$service" "$primary_dns" "$secondary_dns" "$tertiary_dns"
/usr/sbin/networksetup -setsearchdomains "$service" "searchdomain1.com" "searchdomain2.com"
done
just swap in your DNS server addresses and Search Domains for the place holders and scope this to any dual ethernet systems
For single Ethernet systems the adjustment is:
services=("Ethernet" "Wi-Fi")
It is really that simple
Tested this on macOS 10.15 through 13.3 systems and it works
If you are not sure about the network interfaces on a given target system - remote in (if you are able to) and run the following in Terminal.app
networksetup -listallnetworkservices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-16-2013 11:04 AM
I am trying to add multiple search domains to the Ethernet and Wi-Fi adapter. Here are the scripts that I am using - if I do this on the local client it works great, but once I created a script inside jss and created a policy to run that script I get an error
sudo -a -networksetup -setsearchdomains "Ethernet" domain1.edu domain2.edu domain3.edu
sleep 1
sudo -a -networksetup -setsearchdomains "Wi-Fi" domain1.edu domain2.edu domain3.edu
Am I missing something in the script that I created in jss in why this isn't working?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-16-2013 11:09 AM
my guess is there is not a -a option for sudo.
and -networksetup is not an option it is a command that should not have the - so remove -a - from those lines and something more useful might happen.
Also if you are running through the JSS then its already running as root so you dont need sudo at all.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-16-2013 11:18 AM
Thank you thank you thank you nessts - those tips worked.
