Switch Network Locations from the Terminal

Change the active network location (a saved profile of DNS, proxy and service settings) with networksetup -switchtolocation.

macOSconfigurationnetworknetworksetupLow risk
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

RiskLow risk
RequirementsList available locations with `networksetup -listlocations`; create new ones in System Settings > Network (locations menu).

04Undo

Undo
$ networksetup -switchtolocation "Automatic"

05Sources

Last verified: 2026-09-18 · Category: Network