Reputation: 55
Is there a way to programmatically configure network preferences, such as changing the "location" from the command line (bash or shell) on a Mac. I'm trying to call it from another script.
Upvotes: 2
Views: 701
Reputation: 6681
Check out the networksetup
command.
networksetup
: The networksetup command is used to configure network settings typically configured in the System Preferences application. The networksetup command requires at least "admin" privileges to run. Most of the set commands require "root" privileges to run.
sudo networksetup -switchtolocation "location" # set network location
sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4 # set dns servers
# ... and many more! Reference the `networksetup` man page.
Upvotes: 2