MacOS – How to find the currently connected network service from the command line

command linemacosNetworkterminalwifi

I would like to find out which of the available network services (e.g. Ethernet or Wi-Fi) is currently active. In this screenshot from the Network Preferences, you can see that Wi-Fi is currently active (the green dot):

Network Preferences

How can I get that information from the command line?

The networksetup command allows me to list the available network services:

$ networksetup -listallnetworkservices
An asterisk (*) denotes that a network service is disabled.
Ethernet
FireWire
Wi-Fi

It can also show some details on the service, like the device name:

$ networksetup -listnetworkserviceorder
An asterisk (*) denotes that a network service is disabled.
(1) Ethernet
(Hardware Port: Ethernet, Device: en0)

(2) FireWire
(Hardware Port: FireWire, Device: fw0)

(3) Wi-Fi
(Hardware Port: Wi-Fi, Device: en1)

Unfortunately, the info on which service is active (the green dot from the screenshot) is not available in this info. Is there another command that I could use to get this information?

Best Answer

Simply issue

    ifconfig

List all network interfaces and their status.

Related Question