will also tell you if the interface is up. NOTE: Use caution with these methods since they can show out of date information regarding the link's state.
To quickly add to @goo's answer, you would interpret the ip link or ip link show INTERFACE as follows.
This is a port which is administratively up, but physically down:
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
In other words, the UP you can see indicates the system is configured to try and use the NIC for networking. The NO-CARRIER here tells you what the issue preventing networking from working is.
This is a port that is administratively down (its physical layer is 'up', technically - it is a VM):
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
Finally, this port is working normally:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq state UP mode DEFAULT group default qlen 1000
It is administratively UP, the LOWER_UP indicates the physical layer is working (i.e. there is a carrier), and the second UP confirms (in effect) the IP layer is up.
netplugd is a service that can run program(s) when a cable is plugged in or a cable taken out. So the command line would be to grep /var/log/messages or dmesg for netplugd output.
If your system is using ifplugd (e.g. on a Raspberry Pi with Raspbian) then you can use the associated status tool ifplugstatus to obtain the link status of all interfaces:
$ ethtool <eth?>
For example:
provides:
Check
/sys/class/net/eth0/operstate
and other files in this directory.As far as I know this is specific to Linux 2.6+, but it provides a clean interface to the kernel driver.
Full documentation for this part of the
sys
file system can be found here:https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
ethtool [interface]
last line shows what you want:
is another. Good old
or
will also tell you if the interface is up. NOTE: Use caution with these methods since they can show out of date information regarding the link's state.
you should see all statuschanges
You can also use mii-tool to see if the link is up and check the negotiated speed.
To quickly add to @goo's answer, you would interpret the
ip link
orip link show INTERFACE
as follows.This is a port which is administratively up, but physically down:
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
In other words, the
UP
you can see indicates the system is configured to try and use the NIC for networking. TheNO-CARRIER
here tells you what the issue preventing networking from working is.This is a port that is administratively down (its physical layer is 'up', technically - it is a VM):
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
Finally, this port is working normally:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq state UP mode DEFAULT group default qlen 1000
It is administratively
UP
, theLOWER_UP
indicates the physical layer is working (i.e. there is a carrier), and the secondUP
confirms (in effect) the IP layer is up.You can have full details with below command
And if you just want to see link status the give below command
netplugd is a service that can run program(s) when a cable is plugged in or a cable taken out. So the command line would be to grep /var/log/messages or dmesg for netplugd output.
If your system is using
ifplugd
(e.g. on a Raspberry Pi with Raspbian) then you can use the associated status toolifplugstatus
to obtain the link status of all interfaces:or a specific interface (e.g. eth0):