Linux 系统中查看当前网卡流量的命令通常使用 ifconfig
或 ip
命令。这些命令可以显示网络接口的详细信息,包括接收和发送的数据量。
ifconfig
和 ip
。nethogs
、iftop
等,这些工具提供了更详细的流量监控和分析功能。ifconfig
命令查看网卡流量ifconfig eth0
输出示例:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:29ff:fe01:2345 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:01:23:45 txqueuelen 1000 (Ethernet)
RX packets 123456 bytes 123456789 (123.4 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 654321 bytes 987654321 (987.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ip
命令查看网卡流量ip -s link show eth0
输出示例:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:01:23:45 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
123456789 123456 0 0 0 0
TX: bytes packets errors dropped carrier collsns
987654321 654321 0 0 0 0
ifconfig
命令在某些 Linux 发行版中不可用?原因:ifconfig
命令在一些现代的 Linux 发行版中可能已被弃用,取而代之的是 ip
命令。
解决方法:
net-tools
包(如果 ifconfig
被弃用):net-tools
包(如果 ifconfig
被弃用):ip
命令:ip
命令:解决方法:
ip -s link show up
这将列出所有处于 UP
状态的网络接口及其流量信息。
通过以上方法,你可以有效地监控和分析 Linux 系统中的网络流量。
领取专属 10元无门槛券
手把手带您无忧上云