Difference between network service disabled, inactive and interface down

There are (at least) four difference ways for me to disable my Wi-Fi on my Mac:

  1. Click on the Wi-Fi icon in the menu bar and select "Turn Wi-Fi Off"
  2. System Preferences->Network, select Wi-Fi, click Cog, select Make Service Inactive
  3. sudo ifconfig en0 down
  4. networksetup -setnetworkserviceenabled Wi-Fi off

The first two are equivalent, i.e. they change the same setting.

What I'd like to understand is, at a low level, what are the fundamental differences between 1, 3 and 4?


Turning the wifi off through the Menu Bar is equivalent to:

networksetup -setairportpower en0 off

... and so, the same as turning it off in network settings.

I cannot speak to the low levels, but networksetup is an Apple addition, whereas ifconfig is standard not just for BSD, but for Linux as well. (Though the two utilties are ultimately distinct, not just in their implementation but API)

If I had to guess, and I will guess since Apple's internals aren't exactly transparent (please, someone correct me if you're able), networksetup is meant to control the actual hardware, the Wi-Fi device, whereas ifconfig is a purely OS-level utility. Much like you can quit your video-chat app, vs put a piece of tape over the camera.

A few things I can verify:

  1. To function, both the interface, say, en0, must be UP (so, ifconfig en0 up), as well as airportpower being ON (so, networksetup -setairportpower en0 on).
  2. Both downing an iface, and turning airportpower off, will render the Menu Bar symbol as a hollow outline.
  3. BUT, if both DOWN/off, if you bring airportpower on, if ifconfig ... up has not been run after running ifconfig ... down, then the symbol will not be hollow, and macOS will scan frantically for networks, but be unable to: (1) connect to a network (2) bring UP the iface0 (3) change the routing table

So, that wifi symbol seems to be the result of a state-change, not actual state. In that, the actual state of whether or not Wi-Fi is being shown as able to connect isn't connected to the visual indicator. But the interface, even when DOWN, does seem to somehow scan in a way, in that if you turn back on the airportpower, the "status:" given by ifconfig will swap rapidly back & forth between active and inactive, even if the actual interface is not UP.

So, there is inconsistency. But it's that way because there would be no reason to turn the second one off after doing so the first. And because Apple's desires & ideal API differ from those of BSD.