Use NTOP's sflow monitor Enterprise traffic
前言Ntop是一个基于libpcap开发的流量分析和flow收集系统,遵守GPLv3。版本分为pro与community版本,其中community为免费版,它的功能如下:
.根据网络流量的使用状况来排序协议。
.查看网络流量和IPv4/v6的活动主机。
.数据以RRD格式存储在磁盘并可持续流量统计。
.通过利用由谷歌和HTTP Blacklist提供黑名单服务的分析HTTP流量。
.显示各种协议的IP流量分布。
.分析IP流量并按照源/目的排序。
.显示IP子网流量矩阵
.报告IP协议使用排序按协议类型。
.生成HTML5/AJAX网络流量统计报告。
我们主要使用ISO 多层协议分析与sflow功能。
1.版本信息
plat
info
centos
6.4
Ntopng&nprobe
2.0
2.部署信息
2.1 查看系统信息
# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.4 (Final)
Release: 6.4
Codename: Final
2.2 安装epel扩展库
# mkdir code
# cd code/
# wgethttp://mirrors.opencas.cn/epel//6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm:Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing... ###########################################
1:epel-release ###########################################
#yum --disablerepo=epel–y update ca–certificates
# yum list
# yum install -y ntp
# ntpdate time.windows.com
13 Jul 12:01:32 ntpdate: step timeserver 104.41.150.68 offset 104.068333 sec
# hwclock –w
2.3 安装ntopng的依赖包
# yum install -y GeoIP-devel GeoIP redis
# yum install -ylibpcap-devel glib2-devel glibc libxml2-devel redis autoconf automake sqlite-devel numactl
# yum install -y rrdtool* gcc gcc-c++
# service redis start
Starting redis-server: [确定]
2.4安装ntopng
自动安装
This directory contains nightly builds (SVNcode) of 64 bit binary packages for RedHat/CentOS (latest OS version). Pleaseuse rpm-stable.ntop.org for stable builds.
In order to use the repository you need tocreate a file named /etc/yum.repos.d/ntop.repo containing
# cat /etc/yum.repos.d/ntop.repo
name=ntop packages
baseurl=http://www.nmon.net/centos/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.nmon.net/centos/RPM-GPG-KEY-deri
name=ntop packages
baseurl=http://www.nmon.net/centos/$releasever/noarch/
enabled=1
gpgcheck=1
gpgkey=http://www.nmon.net/centos/RPM-GPG-KEY-deri
and also install the/etc/yum.repos.d/epel.repo extra repositories
# cat /etc/yum.repos.d/epel.repo
name=Extra Packages for Enterprise Linux X- $basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-X&arch=$basearch
failovermethod=priority
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-X
Note: replace X with 6 (for CentOS 6) or 7(for CentOS 7) then do:
yum clean all
yum update
yum install pfring n2disk nprobe ntopngntopng-data nbox
手工安装
离线安装:
RPM格式
网站:http://www.nmon.net/packages/rpm/x86_64/
wget http://www.nmon.net/packages/Packages/ntopng-2.0.150630-216.x86_64.rpm
wget http://www.nmon.net/packages/Packages/ntopng-data-2.0.150630-216.noarch.rpm
源代码格式:
网站:http://sourceforge.net/projects/ntop/files/ntopng/
tar -zxvf ntopng-2.0.tar.gz
在线安装:使用流行的github.com作为源
nDPI
git clone https://github.com/ntop/nDPI.git
cd nDPI
./configure –with-pic
make
git clonehttps://github.com/ntop/ntopng.git
cd ntopng
./autogen.sh
./configure
make
make install
-------------------
2.5 ntopng 配置详解
需要添加配置文件
#mkdir –p /etc/ntopng/
#vi/etc/ntopng/ntopng.conf
ntopng.conf是ntopng启动时需要的配置文件。下面我们来查看一下具体文件,
# vi ntopng.conf
-G=/var/tmp/ntopng.gid #-G指定运行所用进程号文件。
--local-networks 192.168.60.0/22#--local-network指定本地子网段
--interface eth0 #--interface 0 指定监听eth0网卡上的流量
--user nobody #匿名登陆,可选
--http-port 8000 #指定web服务端口,如果不指定默认为3000
2.6启动ntopng服务
在运行ntopng之前,要确认先启动redis服务,redis为ntopng提供键值存储。我们这边重新启动一下redis服务。
# service redis restart
Stopping redis-server: [确定]
Starting redis-server: [确定]
# /usr/local/bin/ntopng /etc/ntopng/ntopng.conf
# netstat -ntulp
Active Internet connections (onlyservers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 2069/redis-server
tcp 0 0 0.0.0.0:779 0.0.0.0:* LISTEN 2717/rpc.statd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2674/portmap
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3013/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 3026/cupsd
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 3084/ntopng
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3051/sendmail
tcp 0 0 :::22 :::* LISTEN 3013/sshd
2.7.正常访问
(1).http://192.168.60.4:8000,默认的用户名和密码是admin。
现在为普通流量监控模式,将需要的监控的端口镜像给ntopng。
2.7.1 活动的流
BOGON,表示不应该出现在公共网络中的私有IP资源,特指10.0.0.0/8、172.16-31.0.0/16、192.168.0.0/24
其实我们可以检测到所有网内主机的通信流,使用的IP地址,对端IP,端口号,协议,持续时间,速率等。
http://s3.运维网.com/wyfs02/M02/6F/A0/wKioL1Wje8qhQ_A2AALMnVCxXus757.jpg
2.7.2 检测到的主机
http://s3.运维网.com/wyfs02/M02/6F/A3/wKiom1WjekfQr0sqAAKU6UiMFz4625.jpg
2.7.3 自治系统
网络中IP地址涉及到的Internet AS区域,依据NTOP检测到的ip匹配GeoIP离线数据库的结果。
http://s3.运维网.com/wyfs02/M02/6F/A0/wKioL1WjfGnQMgS5AAKYi2fgng4389.jpg
2.7.4 主机国别归属
http://s3.运维网.com/wyfs02/M02/6F/A3/wKiom1WjeqTwzIqbAAFu8lO1zKs441.jpg
2.7.5 网内主机关联图
http://s3.运维网.com/wyfs02/M01/6F/A0/wKioL1WjfR2xq-k8AAFwLP_KLZ4366.jpg
2.7.6 主机相关信息
http://s3.运维网.com/wyfs02/M01/6F/A3/wKiom1Wje2qBCN1gAAMxhGQ7Rhg679.jpg
2.7.7协议分析状态
http://s3.运维网.com/wyfs02/M02/6F/A3/wKiom1Wje4mAPUspAAJa8nUAG_w962.jpghttp://s3.运维网.com/wyfs02/M00/6F/A0/wKioL1WjfXSwGCqKAAKjxYgRED0808.jpg
3.配置sflow
DataCollector (ntopng)
ntopng -i tcp://127.0.0.1:5556
Probe (nProbe)
nprobe--zmq "tcp://*:5556" -i eth1 -n none (probe mode)
nprobe--zmq "tcp://*:5556" -i none -n none --collector-port 2055(sFlow/NetFlow collector mode)
# ntopng -i tcp://127.0.0.1:5556 -d /var/tmp -w 8000
# nprobe --collector-port 6343 --zmq tcp://127.0.0.1:5556
Cisco device:
(config)#sflow enable
(config)#sflow destination 192.168.6.106343
(config)#sflow polling-interval 1
(config)#sflow sample 10240
(config)#interface ethernet 1/6
(config-if-e1000-1/6)#sflow forwarding
H3C device:
system-view
interface vlan-interface 1
ip address 192.168.6.254 24
quit
sflow agent ip 192.168.6.254
sflow collector ip 192.168.6.10 port 6343
sflow interval 30
interface gigabitethernet2/0/1
sflow enable inbound
sflow enable outbound
sflow sampling-rate 100000
sflow sampling-mode random
display sflow
sFlow Version: 5
sFlow Global Information:
Agent IP:192.168.6.254
Collector IP:192.168.6.10Port:6343
Interval(s): 30
sFlow Port Information:
Interface Direction Rate Mode Status
GE2/0/1 In/Out 100000 Random Active
http://s3.运维网.com/wyfs02/M01/6F/A3/wKiom1Wje8_gyoEaAAKdYVwBL6Y295.jpg
以上为NTOP的普通模式与使用sflow分析网络的部署全过程,希望对需要的friends有所帮助。
sflow对于网络分析是非常重要的技术之一。
页:
[1]