ip コマンドでネットワーク通信量を確認する

先日スマートフォンのテザリングを利用して利用量を確認するのに ifconfig コマンドを利用して確認しました.しかしこのコマンドはそろそろ使わないようにして ip コマンドで確認したいところ.ということで ip コマンドでの確認方法を調べました.


ifconfigではRX/TXの部分を見ると確認できます.しかし,ifconfig(net-tools)は廃止されつつあります.(し,i386では4GiBでロールオーバーするので使いづらかった.)

ifconfigでの例
$ ifconfig wlp3s0
wlp3s0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC>  mtu 1500
        inet 192.168.68.105  netmask 255.255.255.0  broadcast 192.168.68.255
        inet6 fe80::15e:8b89:d7d6:6be5  prefixlen 64  scopeid 0x20<link>
        ether 60:67:20:89:ae:0e  txqueuelen 1000  (Ethernet)
        RX packets 5689437  bytes 3616055367 (3.3 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5206148  bytes 2279169520 (2.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ip コマンドで調べられたはずとmanを確認してみます.

man ip
-s, -stats, -statistics
       Output more information. If the option appears twice or more,
       the amount of information increases.  As a rule, the information
       is statistics or some time values.

-s オプションが使えそうです. ip link show <インターフェイス名>-s を付けることで通信量を確認できました.

$ ip link show wlp3s0
3: wlp3s0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 60:67:20:89:ae:0e brd ff:ff:ff:ff:ff:ff
$ ip -s link show wlp3s0
3: wlp3s0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 60:67:20:89:ae:0e brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped missed  mcast
    3604808992 5665919  0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    2272952739 5184860  0       0       0       0

しかし ip コマンドはサブコマンドたくさんでなかなか覚えられないですね…….
レガシーなコマンド使わないようにして覚えなければ.

環境
$ dpkg-query -W net-tools iproute2
iproute2	5.10.0-4
net-tools	1.60+git20181103.0eebece-1
$ lsb_release -dr
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
$ arch
x86_64

One thought to “ip コマンドでネットワーク通信量を確認する”

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)