永发信息网

在Linux下怎么查看网络接口的速率?

答案:2  悬赏:0  手机版
解决时间 2021-12-20 10:02
  • 提问者网友:最爱你的唇
  • 2021-12-19 20:45
我想知道目前网口是工作在10M,100M还是1000M上。我知道用dmesg| grep eth0可以看到一定量的信息,但不知道有没有更准确好用的办法。
最佳答案
  • 五星知识达人网友:毛毛
  • 2021-12-19 22:01
# 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: Yes
Speed: 10Mb/s
Duplex: Half
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0×00000007 (7)
Link detected: yes

# ethtool -s eth0 speed 100 duplex full autoneg off

# 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
Duplex: Full
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0×00000007 (7)
Link detected: yes

前两天在51cto 6个豆豆下的资料,挺不错的,匿名,没法给你。。= . =...
全部回答
  • 1楼网友:鱼忧
  • 2021-12-19 22:07
写个脚本查看:脚本如下、加x权限、执行就可看以了 #!/bin/bash while [ "1" ] do eth=$1 rxpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') txpre=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') sleep 1 rxnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $2}') txnext=$(cat /proc/net/dev | grep $eth | tr : " " | awk '{print $10}') clear echo -e "\t rx `date +%k:%m:%s` tx" rx=$((${rxnext}-${rxpre})) tx=$((${txnext}-${txpre})) if [[ $rx -lt 1024 ]];then rx="${rx}b/s" elif [[ $rx -gt 1048576 ]];then rx=$(echo $rx | awk '{print $1/1048576 "mb/s"}') else rx=$(echo $rx | awk '{print $1/1024 "kb/s"}') fi if [[ $tx -lt 1024 ]];then tx="${tx}b/s" elif [[ $tx -gt 1048576 ]];then tx=$(echo $tx | awk '{print $1/1048576 "mb/s"}') else tx=$(echo $tx | awk '{print $1/1024 "kb/s"}') fi echo -e "$eth \t $rx $tx " done
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯