问题原文
原帖链接 · 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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
