When configuring enterprise Wi-Fi 802.1X authentication, assigning static IP reservations on corporate DHCP servers, or configuring firewall rules, network administrators need to map physical network ports to their corresponding BSD device identifiers (such as en0, en1, or bridge0). While the standard Unix command ifconfig lists all network interfaces, its output is cluttered with dozens of virtual tunnel adapters (utun), packet filter interfaces, and bridge nodes without clearly explaining which physical connector corresponds to which device name.
macOS includes a specialized, native network configuration framework command: networksetup -listallhardwareports. This command queries the macOS I/O Kit hardware registry to produce an unambiguous, clean mapping of physical hardware ports, device names, and factory MAC addresses. This guide demonstrates how to execute, filter, and automate hardware port discovery in macOS Terminal.
Executing networksetup -listallhardwareports
Open Terminal and run the native command (no elevated sudo permissions required for read queries):
networksetup -listallhardwareports
Deconstructing the Output
The command returns a clean, structured block for every physical and virtual hardware adapter recognized by macOS:
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: f4:d4:88:5a:2b:11
Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: f4:d4:88:5a:2b:12
Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: f4:d4:88:5a:2b:13
Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: f4:d4:88:5a:2b:14
VLAN Configurations
===================
In this output:
- Hardware Port: The human-readable name displayed in macOS System Settings (e.g. Wi-Fi, Thunderbolt Ethernet).
- Device: The BSD kernel device interface identifier used by command-line tools like
ifconfig,tcpdump, androute(e.g.en0). - Ethernet Address: The permanent, physical hardware Media Access Control (MAC) address burned into the network controller silicon.
Practical Scripting and Automation Examples
1. Isolating the Wi-Fi Hardware Interface
Because Mac models assign Wi-Fi to en0 on MacBooks but occasionally to en1 on desktop Mac Pro or Mac Studio models with dual Ethernet, automated scripts should dynamically detect the active Wi-Fi port rather than hardcoding en0:
# Dynamically extract active Wi-Fi interface name
WIFI_INT=$(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')
echo "Active Wi-Fi interface is: $WIFI_INT"
2. Extracting Physical MAC Address for DHCP Reservations
Retrieve the physical MAC address of the primary Wi-Fi hardware adapter cleanly without extraneous text:
networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; getline; print $3}'
3. Distinguishing Physical Hardware from Virtual VPNs
Unlike ifconfig (which mixes physical interfaces with dozens of ephemeral virtual interfaces like utun0, utun1, llw0, and awdl0), networksetup -listallhardwareports strictly enumerates physical hardware controllers, providing a pristine hardware inventory.
macOS Network Discovery Commands Comparison
| Command | Primary Output Scope | Best Administrative Use Case |
|---|---|---|
networksetup -listallhardwareports |
Physical hardware ports, BSD device mapping, factory MAC | Locating physical interface IDs and hardware inventory |
networksetup -listallnetworkservices |
Active macOS network service configurations | Auditing service order priority in System Settings |
ifconfig |
Raw kernel socket states, MTU, packet counters, IP leases | Low-level packet and IP routing debugging |