http://www.unixmen.com/linux-basics-check-state-network-interface-card
Normally,
we can easily check the state of a network interface card like whether
the cable plugged in to the slot or the network card is up or down in
Graphical mode. What if you have only command line mode? Ofcourse, you
can turn around the system and check for the cable is properly plugged
in, or you can do the same easily from your Terminal. Here is how to do
that. This method is almost same for Debian and RPM based systems.
Check Network Card State
I have two ethernet cards on my laptop. One, eth0, is wired, And another, wlan0, is wireless.
Let us check the state of the eth0.
cat /sys/class/net/eth0/carrier
Sample output:
0
Or, use the following command to check the status.
cat /sys/class/net/eth0/operstate
Sample output:
down
As you see in the above results, the NIC is down or cable is not connected.
Let me plug a network cable to the eth0 slot, and check again.
After plugged in the cable, I executed the above commands:
cat /sys/class/net/eth0/carrier
Sample output:
1
Or,
cat /sys/class/net/eth0/operstate
Sample output:
up
Voila, the eth0 is up or the cable is connected to eth0.
Be
mindful, it doesn’t mean that the IP address has been assigned to the
eth0. The cable is just connected to that slot. That’s all.
Let us check for the wlan0 state.
cat /sys/class/net/wlan0/carrier
Sample output:
1
The result is 1, which means the wlan0 is up and connected.
Or,
cat /sys/class/net/wlan0/operstate
Sample output:
up
Likewise, you can check all the network cards on your machine.
Cheers!
No comments:
Post a Comment