1

What I am trying to do is to get the interface name and the nic name (description) via command line in OS X.

On Windows the following command gives me the result I am looking for: wmic nic get name, index (this outputs for example: 11 Realtek blah )

On OS X I would like to see: en0 Realtek as the output.

Thank you for your help and sorry for my explanations (its late at night and my english is not so good)

3 Answers 3

2

This isn't a pretty way to do it, but it does get you the info you desire:

system_profiler | grep "Interfaces" -A15

The command is slow, mostly because of how much data system_profiler spews out. But as a summary:

  1. system_profiler lists loads of info about the system
  2. | is a "pipe" and puts the output of 1 to another command (3)
  3. grep searches for patterns/words, in our case "Interfaces"
  4. The switch -A15 prints out the 15 lines following the match.

Example output:

  Interfaces:
    en0:
      Card Type: AirPort Extreme  (0x14E4, 0xEF)
      Firmware Version: Broadcom BCM43xx 1.0 (5.106.98.100.17)
      MAC Address: xx:xx:xx:xx:xx:xx
      Locale: FCC
      Country Code: US
      Supported PHY Modes: 802.11 a/b/g/n
      Supported Channels: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165
      Wake On Wireless: Supported
      AirDrop: Supported
      Status: Connected
      Current Network Information:
        mynetwork:
          PHY Mode: 802.11n
          BSSID: xx:xx:xx:xx:xx:xx

You can limit -A15 to a lower number (say 3) to just get the card id and the Firmware version (i.e. That'll be the chipset). If that is too much info, you can always get some info on your interfaces with ifconfig or network setup -listallhardwareports, but neither includes info about the chipset/manu unless you want to parse it out of the MAC address (first 6 chars, I think).

Otherwise, you could look into installing lspci, but that is probably in the scope of another question.

1
networksetup -listallhardwareports

Sample output:

# networksetup -listallhardwareports

Hardware Port: Thunderbolt Ethernet Slot 1
Device: en7
Ethernet Address: 64:4b:f0:10:58:07

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 88:66:5a:00:48:49

Hardware Port: Bluetooth PAN
Device: en6
Ethernet Address: 88:66:5a:08:7b:75

Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: 82:7c:df:e8:bc:01

Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: 82:7c:df:e8:bc:00

Hardware Port: Thunderbolt 3
Device: en3
Ethernet Address: 82:7c:df:e8:bc:05

Hardware Port: Thunderbolt 4
Device: en4
Ethernet Address: 82:7c:df:e8:bc:04

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: 82:7c:df:e8:bc:01

VLAN Configurations
===================

Found at https://aruljohn.com/mac.pl

0

With some clever use of awk/sed you could probably get what you're looking for from this output:

defaults read /Library/Preferences/SystemConfiguration/NetworkInterfaces

To get the list of interfaces on the machine is fairly straightforward:

ifconfig -l

Probably best to read that list in and loop through it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .