怎样在Linux上检查网卡信息

1)如何在 Linux 上使用 ip 命令检查可用的网络接口

在不带任何参数的情况下运行 ip 命令时,它会提供大量信息,但是,如果仅需要可用的网络接口,请使用以下定制的 ip 命令。


  1. # ip a |awk '/state UP/{print $2}'
  2.  
  3. eth0:
  4. eth1:

2)如何在 Linux 上使用 ip 命令检查网络接口的 IP 地址

如果只想查看 IP 地址分配给了哪个接口,请使用以下定制的 ip 命令。


  1. # ip -o a show | cut -d ' ' -f 2,7
  2. ip a |grep -i inet | awk '{print $7, $2}'
  3.  
  4. lo 127.0.0.1/8
  5. 192.168.1.101/24
  6. 192.168.1.102/24

3)如何在 Linux 上使用 ip 命令检查网卡的 MAC 地址

如果只想查看网络接口名称和相应的 MAC 地址,请使用以下格式。

检查特定的网络接口的 MAC 地址:


  1. # ip link show dev eth0 |awk '/link/{print $2}'
  2. 00:00:00:55:43:5c

检查所有网络接口的 MAC 地址,创建该脚本:


  1. # vi /opt/scripts/mac-addresses.sh
  2.  
  3. #!/bin/sh
  4. ip a |awk '/state UP/{print $2}' | sed 's/://' | while read output;
  5. do
  6. echo $output:
  7. ethtool -P $output
  8. done

运行该脚本获取多个网络接口的 MAC 地址:


  1. # sh /opt/scripts/mac-addresses.sh
  2.  
  3. eth0:
  4. Permanent address: 00:00:00:55:43:5c
  5. eth1:
  6. Permanent address: 00:00:00:55:43:5d

4)如何在 Linux 上使用 ethtool 命令检查网络接口速度

如果要在 Linux 上检查网络接口速度,请使用 ethtool 命令。

【声明】:芜湖站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

相关文章