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 查看系统信息

 [root@ntopng~]# 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扩展库

[root@ntopng ~]# mkdir code

[root@ntopng ~]# cd code/ 

 

[root@ntopng code]# wgethttp://mirrors.opencas.cn/epel//6/x86_64/epel-release-6-8.noarch.rpm

[root@ntopng code]# rpm -ivh epel-release-6-8.noarch.rpm

warning: epel-release-6-8.noarch.rpm:Header V3 DSA signature: NOKEY, key ID 217521f6 

Preparing...               ########################################### [100%] 

  1:epel-release          ########################################### [100%] 

 

[root@ntopng code]#yum --disablerepo=epel–y update ca–certificates

 

[root@ntopng src]# yum list

 

[root@ntopng ~]# yum install -y ntp

[root@ntopng ~]# ntpdate time.windows.com

13 Jul 12:01:32 ntpdate[2148]: step timeserver 104.41.150.68 offset 104.068333 sec

[root@ntopng ~]# hwclock –w

 

2.3 安装ntopng的依赖包

 

[root@ntopng ~]# yum install -y GeoIP-devel GeoIP redis

[root@ntopng ~]# yum install -ylibpcap-devel glib2-devel glibc libxml2-devel redis autoconf automake sqlite-devel numactl

[root@ntopng ~]# yum install -y rrdtool* gcc gcc-c++

 

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

[ntop]

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

[ntop-noarch]

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

[epel]

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 配置详解

 

需要添加配置文件

[root@ntopng]#mkdir –p /etc/ntopng/

[root@ntopng]#vi  /etc/ntopng/ntopng.conf

ntopng.confntopng启动时需要的配置文件。下面我们来查看一下具体文件,

[root@ntopng 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服务,redisntopng提供键值存储。我们这边重新启动一下redis服务。

 

[root@ntopng ntopng]# service redis restart

Stopping redis-server:                                     [确定

Starting redis-server:                                     [确定]

[root@ntopng ntopng]# /usr/local/bin/ntopng /etc/ntopng/ntopng.conf

 

[root@ntopng ntopng]# 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/8172.16-31.0.0/16192.168.0.0/24

其实我们可以检测到所有网内主机的通信流,使用的IP地址,对端IP,端口号,协议,持续时间,速率等。

wKioL1Wje8qhQ_A2AALMnVCxXus757.jpg

2.7.2 检测到的主机

wKiom1WjekfQr0sqAAKU6UiMFz4625.jpg

2.7.3 自治系统

网络中IP地址涉及到的Internet AS区域,依据NTOP检测到的ip匹配GeoIP离线数据库的结果。

wKioL1WjfGnQMgS5AAKYi2fgng4389.jpg

2.7.4 主机国别归属

wKiom1WjeqTwzIqbAAFu8lO1zKs441.jpg

2.7.5 网内主机关联图

wKioL1WjfR2xq-k8AAFwLP_KLZ4366.jpg

2.7.6 主机相关信息

wKiom1Wje2qBCN1gAAMxhGQ7Rhg679.jpg

2.7.7协议分析状态

wKiom1Wje4mAPUspAAJa8nUAG_w962.jpgwKioL1WjfXSwGCqKAAKjxYgRED0808.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)

[root@ntopng ntopng]# ntopng -i tcp://127.0.0.1:5556 -d /var/tmp -w 8000

 

[root@ntopng nprobe]# 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:

<Device> system-view 

[Device] interface vlan-interface 1 

[Device-Vlan-interface1] ip address 192.168.6.254 24

[Device-Vlan-interface1] quit 

[Device] sflow agent ip 192.168.6.254 

[Device] sflow collector ip 192.168.6.10 port 6343 

[Device] sflow interval 30 

[Device] interface gigabitethernet2/0/1 

[Device-GigabitEthernet2/0/1] sflow enable inbound 

[Device-GigabitEthernet2/0/1] sflow enable outbound 

[Device-GigabitEthernet2/0/1] sflow sampling-rate 100000 

[Device-GigabitEthernet2/0/1] sflow sampling-mode random 

 

[Device-GigabitEthernet2/0/1] display sflow 

sFlow Version: 5 

sFlow Global Information: 

Agent                   IP:192.168.6.254

 

Collector               IP:192.168.6.10  Port:6343 

Interval(s): 30 

sFlow Port Information: 

Interface    Direction       Rate         Mode      Status 

GE2/0/1       In/Out          100000       Random    Active 


wKiom1Wje8_gyoEaAAKdYVwBL6Y295.jpg

以上为NTOP的普通模式与使用sflow分析网络的部署全过程,希望对需要的friends有所帮助。

sflow对于网络分析是非常重要的技术之一。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章