Linux 中查看网卡是否启用
方式一:查看 dev 文件cat /proc/net/dev返回信息如下:[root@aaa build]# cat /proc/net/devInter-|Receive|Transmitface |bytespackets errs drop fifo frame compressed multicast|bytespackets errs drop fifo coll
方式一:查看 dev 文件
cat /proc/net/dev
返回信息如下:
[root@localhost ~]# cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ip6tnl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tunl0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth0: 48674378 33431 0 0 0 0 0 0 765815 13948 0 0 0 0 0 0
可以从返回信息看到, eth0 的流量最大。(不看 lo 这一项)
- 最左边的表示接口的名字,
Receive表示收包,Transmit表示发包; bytes表示收发的字节数;packets表示收发正确的包量;errs表示收发错误的包量;drop表示收发丢弃的包量;
注意:lo 是回环接口,是一个虚拟网络接口,并非真实存在,并不真实地从外界接收和发送数据包,而是在系统内部接收和发送数据包,因此虚拟网络接口不需要驱动程序。因为:如果包是由一个本地进程为另一个本地进程产生的,它们将通过外出链的 lo 接口,然后返回进入链的 lo 接口。
ethtool eth0 | grep Link
方式二:使用 ifconfig 命令

没亲测过。地址:https://jingyan.baidu.com/article/f25ef2546ffde3482d1b8278.html
方法三:使用 ifconfig 命令,搭配 ethtool 工具
首先使用 ifconfig 命令,查看有哪些网卡,比如有 eth0 , eth1 ,则使用 ethtool 来查看
ethtool eth0
返回信息如下:
[root@localhost ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No 注:自动协商关闭
Speed: 100Mb/s 注:速度 100Mb
Duplex: Full 注:全双工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes 注:eth0已经激活;
返回信息中,Link detected: yes 表示 eth0 已经激活。 ethtool 工具功能非常强大,下面是永久修改网络配置的两种方式。
将 ethtool 设置永久保存在网络设备的方法
解决方法一:
ethtool 设置可通过 /etc/sysconfig/network-scripts/ifcfg-ethX 文件保存,从而在设备下次启动时激活选项。
例如:
ethtool -s eth0 speed 100 duplex full autoneg off
此指令将 eth0 设备设置为全双工自适应,速度为100Mbs。
若要 eth0 启动时设置这些参数,修改文件 /etc/sysconfig/network-scripts/ifcfg-eth0 ,添加如下一行:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"
解决方法二:
将 ethtool 设置写入 /etc/rc.d/rc.local 之中。
更多推荐

所有评论(0)