赞
踩
Linux 中查看网卡流量工具有 iptraf
、iftop
以及 nethogs
等,iftop 可以用来监控网卡的实时流量(可以指定网段)、反向解析IP、显示端口信息等。
CentOS yum 方式
# 安装依赖
yum install flex byacc libpcap ncurses ncurses-devel libpcap-devel
yum install iftop -y
Debian/Ubuntu 系统
apt-get install iftop
源码安装
wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz
tar zxvf iftop-0.17.tar.gz
cd iftop-0.17
./configure
make && make install
iftop -h | [-npblNBP] [-i interface] [-f filter code] [-F net/mask] [-G net6/mask6]
参数
-i 设定监测的网卡,如:iftop -i eth1,其中eth1是服务器的公网网卡,(网卡名称可以通过ifconfig查看)
-F 显示特定网段的进出流量,如 `iftop -F 10.10.1.0/24` 或 `iftop -F 10.10.1.0/255.255.255.0`
-B 以Byte为单位显示流量(默认是bits), 如:`iftop -i eth1 -B -F 182.92.*.20` 显示 182.92.*.20这个IP与服务器的网卡eth1交互的数据量,单位是Byte。
-n 使host信息默认直接都显示IP,如:iftop -n
-N 使端口信息默认直接都显示端口号,如: iftop -N
-h(display this message),帮助,显示参数信息
-p 使用这个参数后,中间的列表显示的本地主机信息,出现了本机以外的IP信息;
-b 使流量图形条默认就显示;
-f 这个暂时还不太会用,过滤计算包用的;
-P 使host信息及端口信息默认就都显示;
-m 设置界面最上边的刻度的最大值,刻度分五个大段显示,例:iftop -m 100M
[fenglepeng@centos]# iftop 1.91Mb 3.81Mb 5.72Mb 7.63Mb 9.54Mb mqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqq bogon => 10.117.49.124 103Kb 43.1Kb 43.5Kb <= 331Kb 150Kb 180Kb bogon => bogon 42.9Kb 8.58Kb 2.18Kb <= 1.84Kb 376b 131b bogon => localhost 42.7Kb 8.55Kb 2.17Kb <= 1.66Kb 339b 122b bogon => BJ-DZ0101360.baidu.com 1.86Kb 2.88Kb 3.47Kb <= 184b 394b 599b bogon => 10.117.49.125 2.68Kb 1.15Kb 1.20Kb <= 1.01Kb 1.99Kb 2.54Kb bogon => 10.117.49.123 2.68Kb 1.15Kb 1.20Kb <= 1.01Kb 1.99Kb 2.54Kb bogon => 10.117.49.128 2.68Kb 1.15Kb 1.20Kb <= 1.01Kb 1.99Kb 2.54Kb bogon => 10.117.49.126 2.68Kb 1.15Kb 1.20Kb <= 1.01Kb 1.99Kb 2.54Kb bogon => 10.117.49.127 2.68Kb 1.15Kb 1.20Kb <= 1.01Kb 1.99Kb 2.54Kb bogon => bogon 0b 0b 0b <= 908b 1.13Kb 970b bogon => 10.117.49.12 0b 0b 0b <= 972b 972b 930b qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq TX: cum: 771KB peak: 204Kb rates: 204Kb 69.3Kb 57.7Kb RX: 2.63MB 1.01Mb 350Kb 172Kb 205Kb TOTAL: 3.39MB 1.18Mb 554Kb 241Kb 263Kb
界面说明
<=
与=>
,表示的是流量的方向。TX
:从网卡发出的流量 。RX
:网卡接收流量。TOTAL
:网卡发送接收总流量。cum
:iftop开始运行到当前时间点的总流量。peak
:网卡流量峰值。rates
:分别表示最近2s、10s、40s 的平均流量。Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。