在 Linux 中,ifconfig 本身可以查看网络接口的流量统计,但并不直观,而且在新系统中 ifconfig 已被 ip 命令取代。下面分几种方式说明。
执行:
ifconfig eth0
(把 eth0 换成你的网卡名,如 ens33、wlan0)
你会看到类似:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.10 netmask 255.255.255.0
RX packets 123456 bytes 123456789 (117.7 MiB)
TX packets 654321 bytes 987654321 (942.0 MiB)
含义:
packets:接收包数bytes:接收总字节数packets:发送包数bytes:发送总字节数⚠️ 注意:
ip 命令(现代方式)ip -s link show eth0
watch 动态观察watch -n 1 "ifconfig eth0 | grep bytes"
或
watch -n 1 "ip -s link show eth0"
iftop(实时速率)sudo iftop -i eth0
nloadnload eth0
vnstat(按天/月统计)vnstat -i eth0
| 需求 | 推荐命令 |
|---|---|
| 看累计流量 | ifconfig / ip -s |
| 看实时速率 | iftop / nload |
| 长期统计 | vnstat |
如果你告诉我:
我可以给你更精确的命令。