在 Linux 中,ifconfig 本身可以查看网络接口的流量统计信息,但它不是实时流量监控工具。下面是常用方法:
ifconfig eth0
或(新系统可能用 ip):
ip -s link show eth0
RX packets 123456 bytes 987654321
TX packets 654321 bytes 123456789
✅ 这些是系统启动以来的累计流量
ifconfig eth0 | grep bytes
sleep 10
ifconfig eth0 | grep bytes
手动计算差值即可。
ip 命令(推荐)ip -s -h link show eth0
watch + ifconfig(每秒刷新)watch -n 1 "ifconfig eth0 | grep bytes"
# 实时速率
iftop
# 简单流量统计
nload
# 综合监控
sar -n DEV 1
echo "987654321 bytes = $((987654321/1024/1024)) MB"
ifconfig:看累计流量watch + ifconfig:看变化趋势iftop / nload / sar:看实时速率如果你是 测服务器流量、限速、排查异常流量,可以告诉我使用场景,我给你更合适的命令。