1. 安装
安装指令:
rpm -ivhU iftop-1.0pre4-1.ctl2.x86_64.rpm
2. 使用方式
iftop
输出界面主要包括三部分
- 输出最上面一行,显示网卡带宽流量
- 中间可分为左中右三列,左列和中列记录了哪些IP和主机正在连接本机的网络
- 左列的流量图形条可直观看出IP流量大小
- 中列的 => 代表发送数据,<= 代表接收数据
- 最右列的三小列分别表示外部IP连接到本机2s、10s、40s的平均流量
- 最下面可分为三行
- TX:发送的数据,RX:接受的数据,TOTAL:发送和接受全部数据
- cum:从运行iftop到目前的发送,接受和总数据流量
- peak:发送,接受以及总的流量峰值
- rates:过去2s、10s、40s的平均流量值
3. 相关参数
3.1. 查看帮助
iftop -h
[root@master1 ~]# iftop -h
iftop: display bandwidth usage on an interface by host
Synopsis: iftop -h | [-npblNBP] [-i interface] [-f filter code]
[-F net/mask] [-G net6/mask6]
-h display this message
-n don't do hostname lookups
-N don't convert port numbers to services
-p run in promiscuous mode (show traffic between other
hosts on the same network segment)
-b don't display a bar graph of traffic
-B display bandwidth in bytes
-a display bandwidth in packets
-i interface listen on named interface
-f filter code use filter code to select packets to count
(default: none, but only IP packets are counted)
-F net/mask show traffic flows in/out of IPv4 network
-G net6/mask6 show traffic flows in/out of IPv6 network
-l display and count link-local IPv6 traffic (default: off)
-P show ports as well as hosts
-m limit sets the upper limit for the bandwidth scale
-c config file specifies an alternative configuration file
-t use text interface without ncurses
Sorting orders:
-o 2s Sort by first column (2s traffic average)
-o 10s Sort by second column (10s traffic average) [default]
-o 40s Sort by third column (40s traffic average)
-o source Sort by source address
-o destination Sort by destination address
The following options are only available in combination with -t
-s num print one single text output afer num seconds, then quit
-L num number of lines to print
iftop, version 1.0pre4
翻译:
-i 指定需要检测的网卡
-n 将输出的主机信息都通过 IP 显示,不进行 DNS 解析
-B 将输出以 byte 为单位显示网卡流量,默认是 bit
-p 以混杂模式运行 iftop,此时 iftop 可以用作网络嗅探器
-N 只显示连接端口号,不显示端口对应的服务名称
-P 显示主机以及端口信息
-F 显示特定网段的网卡进出流量 如 iftop -F 192.168.85.0/24
-m 设置输出界面中最上面的流量刻度最大值,流量刻度分 5 个大段显示 如 iftop -m limit
-f 使用筛选码选择数据包来计数 如 iftop -f filter code
-b 不显示流量图形条
-c 指定可选的配置文件 如 iftop -c config file
-t 使用不带 ncurses 的文本界面,
如下两个是只和-t 一起用的:
-s num num 秒后打印一次文本输出然后退出
-L num 打印的行数
3.1.1. -i指定需要检测的网卡
监控本机eth0网卡流量
iftop -i eth0
3.1.2. -n 将输出的主机信息都通过 IP 显示,不进行 DNS 解析
iftop -n
3.1.3. -B 以 byte 为单位显示网卡流量,默认是 bit
iftop -B
3.1.4. -p 以混杂模式运行 iftop,此时 iftop 可以用作网络嗅探器
iftop 中使用混杂模式来捕获所有经过网络接口的数据包,而不仅仅是目标主机的数据包。这样可以更全面地监控网络流量。
iftop -p
3.1.5. -P 显示主机以及端口信息
3.1.6. -F 显示特定网段的网卡进出流量
iftop -F 192.xxx.xx.xx:999
3.2. 进入监控界面后操作命令(区分大小写)
按 h 切换是否显示帮助;
按 n 切换显示本机的 IP 或主机名;
按 s 切换是否显示本机的 host 信息;
按 d 切换是否显示远端目标主机的 host 信息;
按 t 切换显示格式为 2 行/1 行/只显示发送流量/只显示接收流量;
按 N 切换显示端口号或端口服务名称;
按 S 切换是否显示本机的端口信息;
按 D 切换是否显示远端目标主机的端口信息;
按 p 切换是否显示端口信息;
按 P 切换暂停/继续显示;
按 b 切换是否显示平均流量图形条;
按 B 切换计算 2 秒或 10 秒或 40 秒内的平均流量;
按 T 切换是否显示每个连接的总流量;
按 l 打开屏幕过滤功能,输入要过滤的字符,比如 ip,按回车后,屏幕就只显示这个 IP 相关的流量信息;
按 L 切换显示画面上边的刻度;刻度不同,流量图形条会有变化;
按 j 或按 k 可以向上或向下滚动屏幕显示的连接记录;
按 1 或 2 或 3 可以根据右侧显示的三列流量数据进行排序;
按 < 根据左边的本机名或 IP 排序;
按 > 根据远端目标主机的主机名或 IP 排序;
按 o 切换是否固定只显示当前的连接;
按 f 可以编辑过滤代码,这是翻译过来的说法,我还没用过这个!
按!可以使用 shell 命令
按 q 退出监控。