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對於網絡分析是非常重要的技術之一。

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