MacBook power users and roaming systems administrators frequently transition between diverse network environments—including high-security corporate enterprise networks requiring static IP assignments and corporate proxy scripts, lab test environments utilizing isolated subnets, and unrestricted home Wi-Fi networks using dynamic DHCP. Historically, macOS provided a prominent “Network Locations” dropdown inside System Preferences, allowing users to switch complete network profiles with two clicks. Starting in macOS Ventura and continuing through macOS Sonoma and Sequoia, Apple redesigned the interface into System Settings, obscuring manual location controls. Fortunately, the underlying Unix networking layer in macOS retains full location profiling through two native command-line utilities: scselect and networksetup.
Understanding macOS Network Locations and Configuration Daemons
In macOS, network state is maintained within the System Configuration framework (SystemConfiguration.framework) dynamic store. A “Location” (technically termed a configuration “Set”) encapsulates an entire independent snapshot of network service orders, IPv4/IPv6 routing rules, DNS servers, search domains, and proxy bypass lists. The table below delineates the functional differences between scselect and networksetup:
| Command Utility | Operational Scope | Privilege Level Required | Primary Administrative Function |
|---|---|---|---|
scselect |
Location set switching and querying. | Standard user / root. | Instantly lists all defined location sets and switches active sets in milliseconds. |
networksetup |
Full network interface and service configuration. | Administrative privileges (sudo) for modifications. | Creates location sets, assigns static IPs, configures DNS, and toggles hardware power. |
networksetup -listallhardwareports |
Hardware interface mapping. | Standard user. | Maps friendly service names (e.g., Wi-Fi) to BSD device nodes (e.g., en0). |
Querying and Switching Locations with scselect
The scselect (System Configuration Select) command is the fastest tool for querying active sets and executing instantaneous location changes from the Terminal.
1. Listing Defined Network Locations
scselect
The Terminal outputs all configured network sets along with their unique Set Identifiers (GUIDs):
Defined sets include: (* indicates current set)
* 2B8C901A-4D3E-4A12-B8E1-7F2A3B4C5D6E Automatic
6F4A128B-9E3D-4C51-A7D2-1E8F2B3A4C5D Corporate_Office
9D1C2A3B-4E5F-6A7B-8C9D-0E1F2A3B4C5D Lab_Static
The asterisk (*) designates the currently active network location.
2. Switching Locations Instantly
To switch to an alternative profile, pass either the friendly set name or its GUID to scselect:
scselect Corporate_Office
macOS immediately unbinds active network sockets, reconfigures DNS caches, applies corporate proxy parameters, and outputs:
CurrentSet updated to 6F4A128B-9E3D-4C51-A7D2-1E8F2B3A4C5D (Corporate_Office)
Managing Network Locations via networksetup
While scselect only toggles existing locations, networksetup allows administrators to create new sets, duplicate existing profiles, and configure network parameters programmatically.
Step 1: Auditing Hardware Ports and Service Names
Before configuring static routing or DNS, map your physical interfaces:
networksetup -listallhardwareports
Identify which BSD interface corresponds to your network adapter:
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: f4:d4:88:5a:2b:11
Hardware Port: Thunderbolt Ethernet Slot 1
Device: en5
Ethernet Address: 00:e0:4c:68:01:23
Step 2: Creating a New Network Location Set
To create a bespoke network profile named Lab_Isolated populated with baseline device definitions:
sudo networksetup -createlocation "Lab_Isolated" populate
The populate flag automatically clones existing hardware service definitions into the new location, preventing missing interface faults.
Step 3: Switching to the New Location for Configuration
networksetup -switchtolocation "Lab_Isolated"
Configuring Static IP, DNS, and Proxy Parameters
With the target location active, configure bespoke network parameters that remain isolated strictly to this profile without affecting your default “Automatic” home profile.
1. Assigning a Static IPv4 Address
To configure a manual IP address on your primary Ethernet adapter (en5 or service name "Thunderbolt Ethernet"):
sudo networksetup -setmanual "Thunderbolt Ethernet" 192.168.50.150 255.255.255.0 192.168.50.1
To revert an adapter back to standard DHCP auto-addressing:
sudo networksetup -setdhcp "Thunderbolt Ethernet"
2. Specifying Secure DNS Resolvers
Override ISP-provided DNS servers with privacy-centric DNS-over-HTTPS or public resolvers (e.g., Cloudflare and Google DNS):
sudo networksetup -setdnsservers "Wi-Fi" 1.1.1.1 1.0.0.1 8.8.8.8
To clear custom DNS servers and restore default DHCP-assigned nameservers:
sudo networksetup -setdnsservers "Wi-Fi" empty
3. Configuring Corporate HTTP / HTTPS Proxies
When connecting to enterprise networks requiring proxy authentication:
sudo networksetup -setwebproxy "Wi-Fi" proxy.corp.example.com 8080
sudo networksetup -setsecurewebproxy "Wi-Fi" proxy.corp.example.com 8443
sudo networksetup -setproxybypassdomains "Wi-Fi" "*.local" "169.254/16" "10.*"
Automating Location Changes via Shell Scripts
Systems engineers can automate location switching based on ambient environmental conditions (such as the connected Wi-Fi SSID). Create an automated shell script:
#!/bin/bash
CURRENT_SSID=$(ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}')
if [ "$CURRENT_SSID" = "Corporate_Secure_5G" ]; then
scselect Corporate_Office
elif [ "$CURRENT_SSID" = "Lab_Network" ]; then
scselect Lab_Isolated
else
scselect Automatic
fi
Save the script and execute it via a user LaunchAgent triggered upon network state changes to switch configurations seamlessly in the background.
Troubleshooting Network Location Glitches
When switching locations encounters routing stalls or persistent DNS caching:
- Flushing DNS Caches After Location Switch: macOS caches DNS queries in
mDNSResponder. If internal hostnames fail to resolve after toggling profiles, flush the cache immediately:sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Deleting an Obsolete Location: If a temporary location profile becomes redundant, delete it cleanly via:
sudo networksetup -deletelocation "Lab_Isolated" - Cycling Network Hardware Power: If an interface fails to pull a new lease after a profile switch, cycle physical radio power:
networksetup -setairportpower en0 off sleep 1 networksetup -setairportpower en0 on