Rootop 服务器运维与web架构

ntop监控网络流量

| 暂无评论

NTOP是一种网络嗅探器,MRTG基于SNMP获取信息,能够更加直观地将网络
使用量的情况和每个节点计算机的网络带宽使用详细情况显示出来。
NTOP提供以下一些功能:
① 自动从网络中识别有用的信息;
② 将截获的数据包转换成易于识别的格式;
③ 对网络环境中的通信失败进行分析;
④ 探测网络环境下的通信瓶颈;
⑤ 记录网络通信时间和过程;
⑥ 自动识别客户端正在使用的操作系统;
⑦ 可以在命令行和Web两种方式下运行。

目前市场上可网管型的交换机、路由器都支持SNMP,NTOP支持简单网络管理协议,所以可以进行网络流量监控。
NTOP几乎可以监测网络上的所有协议:TCP/UDP/ICMP, (R)ARP, IPX, Telnet, DLC, Decnet, DHCP-BOOTP
AppleTalk, Netbios, TCP/UDP, FTP, HTTP, DNS, Telnet, SMTP/POP/IMAP, SNMP, NNTP, NFS, X11
SSH和基于P2P技术的协议eDonkey, Overnet, BitTorrent, Gnutella (Bearshare, Limewire,etc), Kazaa, Imesh, Grobster。

在早期是通过rrdtool和ntop结合,目前最新版本为ntopng,名字已经改为ntopng,安装应该相对简单。不过我这里依旧采用老方法安装,新版本回头再装一下。

ntop最后一个版本:ntop-5.0.1 发布日期:2012-08-13
http://oss.oetiker.ch/rrdtool/pub/rrdtool.tar.gz
http://nchc.dl.sourceforge.net/project/ntop/ntop/Stable/ntop-5.0.1.tar.gz
http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz  #编译ntop时会用到

安装编译环境:

[root@localhost ~]# yum install -y libtool automake autoconf subversion libpcap libpcap-devel python python-devel libpng gdbm gd gd-devel libxml2 libxml2-devel glib2 glib2-devel pango pango-devel

安装rrdtool(绘图)

[root@localhost rrdtool-1.4.8]# ./configure --prefix=/usr/local/
[root@localhost rrdtool-1.4.8]# make && make install

安装ip地址库:

[root@localhost GeoIP-1.4.8]# ./configure
[root@localhost GeoIP-1.4.8]# make && make install

安装ntop(过程好奇葩啊···)

[root@localhost ntop-5.0.1]# sh autogen.sh --with-tcpwrap
[root@localhost ntop-5.0.1]# make && make install

得到一个提示:
************************************************************
************************************************************

WARNING: This install created a directory for the ntop
files and databases:

/usr/local/share/ntop

This directory MUST be owned by the user
which you are going to use to run ntop.

The command you must issue is something like:

chown -R ntop.ntop /usr/local/share/ntop
or chown -R ntop:users /usr/local/share/ntop

man chown to check the syntax for YOUR system

************************************************************
************************************************************

echo “Shall you be using SELinux please run:”
Shall you be using SELinux please run:
echo “make install-selinux-policy”
make install-selinux-policy
说需要修改/usr/local/share/ntop权限,看意思还支持selinux开启状态下的支持。

[root@localhost ntop-5.0.1]# chown -R nobody /usr/local/share/ntop/ #必须修改为ntop运行账户
[root@localhost ntop-5.0.1]# ntop -A #设置admin用户密码

Wed May 14 13:50:14 2014 Initializing gdbm databases
Wed May 14 13:50:14 2014 Setting administrator password…

ntop startup – waiting for user response!

Please enter the password for the admin user:
Please enter the password again:
Wed May 14 13:50:19 2014 Admin user password has been set
Wed May 14 13:50:19 2014 Admin password set…

因为编译的时候开启了tcp wrapper,所以通过修改tcp wrapper进行访问控制:

[root@localhost ~]# echo "ntop:192.168.0.123" >> /etc/hosts.allow #允许192.168.0.123访问
[root@localhost ~]# echo "ntop:All" >> /etc/hosts.deny     #拒绝其他

启动ntop服务:

[root@localhost ~]# ntop -d -i eth0   #-d 守护进程 -i指定检测网卡,多块网卡通过逗号隔开ntop -d -i eth0,eth1 -M

ntop参数:
-c / –sticky-hosts   保留非活动主机的记录
-P / –db-file-path   指定新的数据存放记录
-u / –user                 指定运行程序的用户身份
-b / –disable-decoders       关闭协议解码器
-n / –numeric-ip-address  使用数字形式的主机标识(不做NDS解析)
-w / –http-server               指定监听HTTP访问的端口(默认为3000)

访问:
通过浏览器访问 http://IPADDRESS:3000/ 即可。
安装完成后,试用了一下,比较适合做局域网的流量监控、分析网络协议什么的。

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/2590.html

作者:Venus

服务器运维与性能优化

发表回复