List All Network Hardware from Command Line in Mac OS

Sep 3, 2014 - 8 Comments

Terminal in Mac OS X

The networksetup utility offers a command line interface to configuring the variety of Mac networking features available in Mac OS X. We’ve discussed networksetup and accompanying features many times here for more advanced purposes, but one of the simpler uses of networksetup is that it can list out every piece of networking hardware attached to a Mac, it’s accompanying device interface, and it’s associated address. This works to list both internal networking components and external connected networking devices as well, so if you’re using an external NIC card, you should find it here.

How to List All Network Hardware on a Mac via Command Line

To see what networking hardware is connected to a given Mac, simply issue the following command string into the Terminal:

networksetup -listallhardwareports

You will see something like the following reported back, which displays the hardware port (which in this case is basically the user friendly name of the interface, like Wi-Fi, Bluetooth, Thunderbolt, Ethernet, etc), the device interface (en1, en0, en3, bridge1, usb1, etc), and the hardware address of the device, called Ethernet Address here, but you may know it better as a devices MAC address, which can be important to know for address filtering and spoofing.

Hardware Port: Bluetooth DUN
Device: Bluetooth-Modem
Ethernet Address: N/A

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: d7:02:65:7c:1e:14

Hardware Port: Bluetooth PAN
Device: en1
Ethernet Address: N/A

Hardware Port: Thunderbolt 1
Device: en2
Ethernet Address: bb:e8:c3:25:2b:12

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: N/A

What’s not listed in the hardware report are external devices that are connected through the networking interfaces, meaning things like routers, relays, switches,any iPhone Personal Hotspot, and tethered or wireless Android hotspots, because those are not considered native hardware, though you can retrieve that data with networksetup as well.

Using “networksetup -listallhardwareports” can be an excellent trick for troubleshooting network devices and connections, particularly if a hardware interface appears to be nonexistent or is having problems.

For example, if a connection is failing to work because you can’t find a specific networking device in Network preference panel of Mac OS X, you can check to see if something like a wifi card is found here, and if so, try to power-cycle it off and on again, which often resolves many of those simple detection problems.

On the other hand, if you know for certain that a piece of hardware is connected but it’s still not showing up, that could point to a hardware problem either with the network card, or with the interface itself. More simply, it also makes it simple to find the device interface, which is necessary if you’re trying to connect to wifi networks from the command line using the same networksetup command.

networksetup has many other uses and extremely advanced features aimed at advanced Mac users, you can find some of the other tricks we’ve covered using the networksetup utility here.


Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. WizIT says:

    Hi everybody,

    I would like to add persistence route on my MacBook to route certain traffic through VPN. The command I am using at terminal is

    sudo route -n add -net

    The command is running fine and doing its job. The problem is that, when MacBook is rebooted, the route entry in the route table resets and route entry get lost, and requires everytime to run this command at terminal.

    How can I make this route permanent/persistent (until I delete) on my MacBook?

  2. XP says:

    Hi again…i wish i have a solution for this.
    My problem is that my one thunderbolt port (i have 2 ,1&2 imac 27″14,2)
    They dont appear correctly at network prefane.
    i did the nice command you post here (thank you) and they appear correctly with correct mac address and correct device number.
    But at network prefane at hardware tab thund 1 and 2 have the same mac address and the en3 is missing !!!
    Why this please?
    Also i have noticed that many settings at latest OSX”S
    they have this problem.
    i wish i could still had support to my old good Snow Leopard ..(: i didnt had even once one simple problem…

  3. andrew says:

    Been using this alias which uses ifconfig:

    alias iflist=”ifconfig | egrep ‘^[a-z]’ | awk ‘{ print \$1 }’ | sed -r -e ‘s/(.*)\:$/\1/'”

    Requres GNU coreutils (if on MacPorts, ‘port install coreutils grep’)

    With that you can use it in a loop:
    for name in $(iflist); do
    alias sniff-${name}=”sudo ngrep -d ${name} -t ‘^(GET|POST|DELETE|PUT) ‘ ‘tcp and port 80′”

    (Install ngrep, ‘port install ngrep’ on MacPorts)

  4. Roy Rieck says:

    I guess this doesn’t work as advertised with the iTerm instead of default terminal. All I get is a list of all the available options for networksetup.

  5. Salvatore Capolupo says:

    This is very useful, thanks for posting that!

  6. Yeraze says:

    How is this any better than the linux standard ‘ifconfig’, which is far fewer letters to type and gives you far more information (like the most important bit, your IP address)?

    • Paul says:

      Indeed ifconfig output is considerably more detailed and also available on linux, but networksetup has arguably more user-friendly output. Aside from that, networksetup can manipulate the network interfaces, turn a NIC card on and off, join networks, disconnect, switch profiles, change DNS, change MTU, and much more. It’s a really great utility, check out networksetup –help for a nice list of uses.

      • Yeraze says:

        Yeah, I get that… and that would be a better “Sales pitch” for the tool rather than showing me what I can already get far simpler with ‘ifconfig’ :)

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site