7

Say that we have the wireless interface wlan0. What does ip link set wlan0 up/down actually do? Power and poweroff the NIC? A lot of network configuration guides online nonchalantly describe it as simply "bringing the interface up", but what does that really mean?

8

When you bring the interface up/down you're merely setting a flag on the driver that the state of the interface is up or down. The NIC is still powered on and can participate in WOL (Wake on LAN) etc.

If you look at the output of the interface the state flag is shown here:

$ ip a l eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:72:14:26 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.101/24 brd 192.168.56.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe72:1426/64 scope link
       valid_lft forever preferred_lft forever

state UP

If I were to tell ip to put it into the down state:

$ ip l set eth1 down

$ ip a l eth1
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 08:00:27:72:14:26 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.101/24 brd 192.168.56.255 scope global eth1
       valid_lft forever preferred_lft forever

But how can you know it's not powered off?

Simple. Use the ethtool to interrogate the NIC further.

$ ethtool eth1
Settings for eth1:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown (auto)
    Supports Wake-on: umbg
    Wake-on: d
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: no

The key piece of this output is the Link detected: no. That's because it's in a DOWN state. If we bring it back up:

$ ethtool eth1 | grep Link
    Link detected: yes

In this case the Link detected: yes means that the NIC is UP and can detect a ethernet cable plugged into it.

Commands used above

Notice that I'm using the shorthand notations for commands:

  • a == addr
  • l == list

There are more... The ip command is "smart enough" to figure out which command or sub-command you're using, and can infer it.

References

| improve this answer | |
  • 1
    What an amazing answer. Answers like this lifts the bar. Thankyou – Avi Mehenwal Sep 25 '19 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.