最近需要查看下Linux的端口和网络连接状态,找了一些工具尝试了下,发现iftop比较好用,这里简单的笔记下使用方法。
CONTENTS
首先看下iftop的帮助命令
cstriker1407@cstriker1407-x64:~$ sudo 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 #不进行hostname反向查询,如果指定了,IP不会显示为已经解析的hostname
-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
-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 #使用正常的text输出模式,不使用ncurses方式,即每次都会刷新console
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
copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors
这里笔记几个常用的命令
直接最简单方式查看
cstriker1407@cstriker1407-x64:~$ sudo iftop -i wlan0 #此时会使用ncurses方式进行交互式查询
cstriker1407@cstriker1407-x64:~$ sudo iftop -i wlan0 -nNPt #当需要明确的网络使用情况时,作者比较喜欢这种方式:text方式,显示端口和IP,而且不进行反向查询。
CentOS如何安装iftop
yum install epel-release yum install iftop
发表评论