查看已安装的网卡硬件
# lspci | grep -i net
# lspci | egrep -i --color 'network|ethernet'
查看网卡名称和状态,如果对Linux中网卡名称有兴趣请查看:https://www.cnblogs.com/zyd112/p/8143464.html
$ ifconfig
启用、停用网卡
# ifdown eth0
# ifup eth0
查看网卡工作模式
# mii-tool -v ens1
ens1: negotiated 1000baseT-FD flow-control, link ok
product info: vendor 00:07:32, model 0 rev 0
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link partner: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
查看网卡连接状态
# dmesg | grep -i ens1
[ 2.998931] r8169 0000:02:00.0 ens1: renamed from eth0
[ 33.495992] IPv6: ADDRCONF(NETDEV_UP): ens1: link is not ready
[ 33.591575] r8169 0000:02:00.0 ens1: unable to load firmware patch rtl_nic/rtl8168h-2.fw (-2)
[ 33.695503] IPv6: ADDRCONF(NETDEV_UP): ens1: link is not ready
[ 33.695537] r8169 0000:02:00.0 ens1: Link is Down
[ 35.285906] r8169 0000:02:00.0 ens1: Link is Up - 100Mbps/Full - flow control rx/tx
[ 35.285942] IPv6: ADDRCONF(NETDEV_CHANGE): ens1: link becomes ready
[1885167.302252] r8169 0000:02:00.0 ens1: Link is Down
[1885177.102509] r8169 0000:02:00.0 ens1: Link is Up - 100Mbps/Full - flow control rx/tx
[2844097.960257] r8169 0000:02:00.0 ens1: Link is Down
[2844101.075416] r8169 0000:02:00.0 ens1: Link is Up - 1Gbps/Full - flow control rx/tx
查看网卡实时流量
方法1:查看/proc/net/dev
$ cat /proc/net/dev
方法2:使用ifconfig可查看端口累计的发包和流量变化从而计算出单位时间流量
$ ifconfig
