本文主要介绍 Linux 操作系统中 iftop 命令的相关内容。
1 概述
Linux 操作系统中的 iftop 命令来自 iftop 软件包,iftop 软件包的描述如下:
Command line tool that displays bandwidth usage on an interface
iftop 手册(man iftop 命令)中的介绍信息如下:
iftop - display bandwidth usage on an interface by host.
iftop listens to network traffic on a named interface, or on the first interface it can find which looks like an external interface if none is specified, and displays a table of current bandwidth usage by pairs of hosts. iftop must be run with sufficient permissions to monitor all network traffic on the interface; see pcap(3) for more information, but on most systems this means that it must be run as root.
总结上述介绍信息,可知:iftop 用于显示网口上的带宽流量信息。
2 命令用法
本章介绍 iftop 命令的常见用法。
2.1 显示ip信息代替主机名
iftop -n
2.1 显示指定ip的流量信息
首先,运行 iftop -n 命令,显示的示例结果如下:
上面的结果默认显示了所有 ip 的流量信息。
现在想只显示 ip 地址“192.168.110.7”的流量信息,操作步骤如下。
1. 在上面的显示结果界面中,输入 l,此时屏幕中会出现“Screen filter”待输入状态,如下图所示:
2. 输入指定的 ip 地址信息(本例中为 192.168.110.7),输入的内容会填充到“Screen filter”,如下图所示:
3. 按下 Enter 键确认。
完成上述操作后,即可只监控指定 ip 地址的流量信息,如下图所示: