iftop网络流量检测工具

iftop网络流量检测工具node

iftop是一款实时流量监控工具,能够监控网卡的实时流量、端口链接信息、反向解析IP等,对流量异常检测、网络故障检测、网络安全检测有很大做用。安全

缺点是功能较为单一,无报表功能,并且多用于单台服务器。服务器

1、iftop安装即常见参数说明网络

安装必要的依赖包工具

[root@node1 ~]# yum install -y libcap libcap-devel ncurses ncurses-devel flex byacc测试

安装iftop:直接使用yum源安装便可flex

[root@node1 ~]# yum install -y iftopui

语法:this

iftop -h | [-npblNBP] [-i interface] [-f filter code]code

                               [-F net/mask] [-G net6/mask6]

参见参数:

-i:指定须要检测的网卡

-n:以ip地址显示输出的主机信息,不进行DNS反向解析

-B:以byte为网卡流量单位,默认是bit

-p:以混杂模式运行iftop,此时iftop可做为网络嗅探器

-N:只显示链接端口号,不显示端口对应的服务名称

-P:显示主机以及端口信息,重要参数

-F:显示特定网段的网卡收发流量

-m <最大刻度b|kb|m|g>:设置iftop输出界面最上边的最大流量刻度,流量刻度分5个大段显示,经测试,目前版本最大支持将1Gb划分红五个。

-h:查看帮助

-b:默认显示流量图形条

查看具体参数:

[root@node3 ~]# 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

   -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

copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors

2、iftop监控网络及输出界面说明

[root@node3 ~]# iftop

interface: ens35

IP address is: 192.168.88.135

MAC address is: 00:0c:29:0b:8a:d2

----动态界面展现----

按下“h”键能够进入交互界面,查看按键操做说明

详细输出界面及交互界面参数说明见下图:

iftop输出界面说明及交互界面参数说明

3、iftop命令使用范例示例

1、监控网络

[root@node3 ~]# iftop

2、进入iftop交互界面:

按“h”键能够进入交互选项界面,该界面会提示不一样参数表示的意义,

分为通常参数、主机显示参数、端口显示参数和输出排序参数,详细按键说明参考上图“iftop监控界面说明”。

[root@node3 ~]# iftop

操做方法:按下“h”键进入-->按下其它功能键-->按下“h”键退出交互选项界面进入网络监控界面

3、只监测特定网卡:监测ens35网卡

[root@node3 ~]# iftop -i ens35

4、只查看192.168.88.0/24网段

[root@node3 ~]# iftop -n -F 192.168.88.0/24

5、修改最大刻度值为100Mb

[root@node3 ~]# iftop -m 100m

|       20.0Mb    40.0Mb    60.0Mb    80.0Mb    100Mb|

6、显示主机以及端口信息

[root@node3 ~]# iftop -P

7、进入混杂模式

[root@node3 ~]# iftop -p