Switch Network Locations from the Terminal
Change the active network location (a saved profile of DNS, proxy and service settings) with networksetup -switchtolocation.
Run `networksetup -switchtolocation "Office"` to activate that location; check the current one with `networksetup -getcurrentlocation`.
01Command
Command
$ networksetup -switchtolocation "Office"02What it does
A network location is macOS's built-in profile system: each one remembers its own DNS servers, proxies and enabled services, so switching applies the whole set at once — the classic setup for laptops that move between home and an office with a corporate proxy. This does the same as the Location menu in System Settings > Network, scriptable and fast. The default location is called 'Automatic'.
03Risk
04Undo
Undo
$ networksetup -switchtolocation "Automatic"05Sources
- networksetup — configure network settings (macOS man page)Evidence: Documents `networksetup -switchtolocation <location>`, `-listlocations` and `-getcurrentlocation` for macOS network locations.
- Use network locations on MacEvidence: Explains network locations as switchable sets of network settings (DNS, proxies, services) for different environments.
Last verified: 2026-09-18 · Category: Network