大网数据广告活动
服务器运维问答

How to get TX/RX bytes without ifconfig?

· 52CE 我爱测

Since ifconfig is apparently being deprecated in major Linux distributions, I thought I'd learn something about the ip tool that's supposed to be used instead of ifconfig . And here I ran into a problem: when run on its own, ifco…

问题原文

原帖链接 · justinas · CC BY-SA 3.0

Since ifconfig is apparently being deprecated in major Linux distributions, I thought I'd learn something about the ip tool that's supposed to be used instead of ifconfig.

And here I ran into a problem: when run on its own, ifconfig shows the number of bytes received/transmitted on each interface besides other info. I couldn't find a way to get this from ip. Is there no such function in this tool? What other built-in tools could I use for getting those stats?

社区高分解答

原帖链接 · Zoredache · CC BY-SA 3.0

The ip command which is part of the the iproute2 package is the new tool. The link subcommand is for managing the devices/interfaces.

If you can get the stats of an interface using ip -s link

root:~# ip -s link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes  packets  errors  dropped overrun mcast
    50679705   529967   0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    50679705   529967   0       0       0       0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:1d:7d:aa:e3:4e brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    187663757  308710386 0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    4051284587 532435117 0       0       0       0

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-08-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。