Network service management on macOS is traditionally performed through the graphical Network pane inside System Settings. However, for systems administrators automating mass device provisioning, managing remote headless Mac mini servers via SSH, or scripting dynamic network switching, graphical configuration is impractical. Furthermore, when network preferences become corrupted or virtual interfaces leave behind ghost entries, the graphical interface often fails to expose or delete lingering adapters.
The native macOS networksetup command-line utility provides complete programmatic control over the operating system’s System Configuration framework. By utilizing service management verbs such as -createnetworkservice, -duplicatenetworkservice, -renamenetworkservice, and -deletenetworkservice, administrators can provision secondary network interfaces on physical ports, establish isolated VLAN/static profiles, and clean up orphaned services directly from Terminal.
Understanding macOS Network Services and Hardware Ports
In macOS networking architecture, an interface is split into two distinct concepts:
- Hardware Port (Physical/Device Layer): The physical or virtual network interface controller recognized by the Darwin kernel, identified by BSD device names such as
en0(Wi-Fi or onboard Ethernet),en1, orbridge0. - Network Service (Logical Layer): A named profile configuration bound to a hardware port (for example, “Wi-Fi”, “Thunderbolt Ethernet”, or “Corporate Static”). Multiple logical network services can be attached to the same physical hardware port, allowing distinct IP, DNS, and proxy configurations.
Auditing Existing Hardware Ports and Active Services
Before creating or deleting network services, identify the exact BSD interface names and currently registered services:
1. Listing All Available Hardware Ports
To inspect physical adapters and their corresponding BSD device nodes:
networksetup -listallhardwareports
The terminal returns a structured list:
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: f4:d4:88:5a:20:12
Hardware Port: Thunderbolt Ethernet
Device: en5
Ethernet Address: 00:e0:4c:68:01:23
Note the Device identifier (e.g., en5) associated with your target port.
2. Listing All Currently Registered Network Services
To view existing logical network service names:
networksetup -listallnetworkservices
An asterisk (*) next to a service indicates that the service is currently disabled.
Creating a New Network Service
To bind a new logical network service to an existing hardware port, use the -createnetworkservice verb. This requires root privileges via sudo:
sudo networksetup -createnetworkservice "Lab Ethernet" en5
This command provisions a new service named “Lab Ethernet” attached to device en5. By default, new services are initialized with DHCP client addressing.
To verify that the service was created:
networksetup -listallnetworkservices
Duplicating an Existing Network Service
Duplicating a network service is ideal when you need multiple configuration profiles (for example, switching between dynamic DHCP and a static IP testing profile) on the exact same physical adapter without overwriting existing settings:
sudo networksetup -duplicatenetworkservice "Thunderbolt Ethernet" "Thunderbolt Static IP"
The newly duplicated service inherits all parameters from the original service but operates as an independent configuration node. You can immediately assign static IP credentials to the duplicate:
sudo networksetup -setmanual "Thunderbolt Static IP" 192.168.10.50 255.255.255.0 192.168.10.1
sudo networksetup -setdnsservers "Thunderbolt Static IP" 1.1.1.1 8.8.8.8
Renaming a Network Service
To keep service naming clean and descriptive across enterprise fleets, rename services using -renamenetworkservice:
sudo networksetup -renamenetworkservice "Lab Ethernet" "Production VLAN 100"
All existing IP, DNS, search domain, and proxy settings are preserved under the new service label.
Enabling and Disabling Network Services
Rather than deleting a service when it is temporarily not needed, disable it to prevent the system from attempting network initialization:
# Disable the service
sudo networksetup -setnetworkserviceenabled "Production VLAN 100" off
# Re-enable the service
sudo networksetup -setnetworkserviceenabled "Production VLAN 100" on
Deleting a Network Service
When an adapter is retired or corrupted network configurations must be purged, delete the service using -deletenetworkservice:
sudo networksetup -deletenetworkservice "Production VLAN 100"
The service is permanently unlinked from the System Configuration store. Note that deleting a network service does not remove or damage the underlying physical hardware port (en5); it only removes the logical software configuration.
Automating Full Network Service Re-Detection
If network services become corrupted or newly attached USB/Thunderbolt adapters fail to appear in System Settings, force macOS to scan hardware buses and automatically recreate default services for all detected ports:
sudo networksetup -detectnewhardware
The operating system re-enumerates all connected network controllers and provisions standard service profiles, restoring healthy network operations without requiring a system reboot.
Mastering networksetup service commands allows macOS engineers to script, repair, and deploy complex networking configurations across Apple hardware efficiently.