iftop是什么?
Iftop 主要用来显示本机网络流量情况及各相互通信的流量集合,如单独同那台机器间的流量大小,非常适合于代理服务器和iptables服务器使用。官方网站:http://www.ex-parrot.com/~pdw/iftop/
iftop有什么用?
iftop可以用来监控网卡的实时流量(可以指定网段)、反向解析IP、显示端口信息等,详细的将会在后面的使用参数中说明。
安装iftop
如果采用编译安装可以到iftop官网下载最新的源码包。安装前需要已经安装好基本的编译所需的环境,比如make、gcc、autoconf等。安装iftop还需要安装libpcap和libcurses。
CentOS上安装所需依赖包:
# yum install -y gcc flex byacc libpcap ncurses ncurses-devel libpcap-devel tcpdump
附:Debian上安装所需依赖包:
# apt-get install flex byacc libpcap0.8 libncurses5
下载源码并编译安装
# cd /usr/local/src # wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz # tar xvf iftop-0.17.tar.gz # cd iftop-0.17 # ./configure --prefix=/usr/local/iftop # make # make install # chmod 700 /usr/local/sbin/iftop #修改IFTOP权限
使用方法
/usr/local/iftop/sbin/iftop /usr/local/iftop/sbin/iftop -i eth0 -n 就可以看到eth0网卡的流量状况 附:Debian系统 运行:apt-get install iftop"
如果安装iftop时没有自定义路径,那么直接运行iftop就可以查看流量统计了,例如:iftop或者iftop -i eth0 -n
相关参数及说明
1、iftop界面相关说明
界面上面显示的是类似刻度尺的刻度范围,为显示流量图形的长条作标尺用的。中间的<= =>这两个左右箭头,表示的是流量的方向。
2、iftop相关参数
常用的参数
进入iftop画面后的一些操作命令(注意大小写)
常见问题1
make: yacc: Command not found make: *** [grammar.c] Error 127
解决方法:
apt-get install byacc / yum install byacc
常见问题2
configure: error: Curses! Foiled again! (Can't find a curses library supporting mvchgat.) Consider installing ncurses.
解决方法:
apt-get install libncurses5-dev / yum install ncurses-devel