centos 網卡狀態

因爲ifconfig命令無法看到網卡的一些狀態, 如下有5種方法查看網卡狀態,是否連通網線ip

1)# dmesg | grep eth
.....
e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

2)# mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD, link ok

3)# ethtool eth0 | grep Link
Link detected: yes

4)# cat /sys/class/net/eth0/operstate
up

5)# ip link show
2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:e4 brd ff:ff:ff:ff:ff:ff
3: eth1: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:b0:ef:ee brd ff:ff:ff:ff:ff:ffast

----------------------------------------------------------------------------class

ifconfig -a

使用ifconfig 命令能夠獲取全部網卡設備的信息,若是須要查看哪些設備鏈接網線,須要經過 RX packets或者TX packets進行判斷,若是數值爲0的話一般表示沒有硬件鏈接。

缺點:
不能直接顯示設備鏈接狀況,須要經過其它參數進行判斷。若是網口鏈接過網線,可能會致使數據不許確,須要使用ifdown、ifup命令重啓設備。
ip a

使用這個命令能夠獲取本機上全部設備的狀態信息, 經過 「qdisc mq state」後面的值是UP仍是DOWN來判斷是否已經鏈接網線。
(此命令對於網線,光纖,InfiniBand類型設備均可以進行支持)
nmcli dev status

使用這個命令能夠獲取本機上全部設備的狀態信息, 經過CONNECTIONZ字段就能夠很方便看出是否有設備鏈接。
推薦的使用方式!

此外,還能夠使用service network status 命令查看當前配置的網卡設備信息。

cli

相關文章
相關標籤/搜索