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 退出監控。