cisco netflow配置

 概述緩存

 

在須要對Cisco設備上查看數據的流量傳輸狀況的時候,咱們能夠用到的技術是IP Accounting,可是能夠看出這個技術記錄出的流量是很是簡潔的,只能看到數據包的量,卻看不到數據包的協議。下面有一項技術在IP Accounting的基礎上增長了一些有用的附加功能,它不只能記錄數據的數量,而且還能夠記錄出協議等信息,這就是NetFlow網絡

Cisco開發的NetFlow4個版本,分別是ver 1 ver 5ver 8ver 9,它們的特色是:ide

V9不向後兼容v8v5,須要獨立開啓。spa

V8只支持聚合緩存,不支持新featureorm

V5只支持主緩存,不支持新feature接口

V1,不要使用,建議用59ip

Netflow在網絡設備上抓包,在每臺設備上獨立進行,不須要全部設備開啓。內存

配置Netflow的條件:ci

1)必須先開啓路由功能,資源

2CEF必開

3)而且會消耗額外CPU和內存資源。

Netflow抓的包包含:

IP-to-IP

IP-to- MPLS

Frame Relay

ATM

egress (outgoing)

下面7個參數相同即被認爲是同一流,做相同記錄,不然另做記錄

1Source IP address

2Destination IP address

3Source port number

4Destination port number

5Layer 3 protocol type

6Type of service (ToS)

7Input logical interface

Netflow抓到的包能夠向遠程主機發送,發送時使用協議UDP,端口號默認爲9996,這些遠程主機的IP和端口號能夠隨意更改。

配置

說明:Netflow是基於接口開啓的,在某個接口開啓後,就在相應接口的相應方向抓取數據包,

在接口上開啓Netflow時,有先決條件須要打開。

 

1.全局開啓CEF(必開)

R1(config)ip cef

2.接口開啓Netflow(可開多個接口)

1)早於IOS版本12.2(14)S, 12.0(22)S, or 12.2(15)T

r1(config)#int f0/0

r1(config-if)#ip route-cache flow

2)等於或晚於IOS版本12.2(14)S, 12.0(22)S, or 12.2(15)T

r1(config)#int f0/0

r1(config-if)#ip flow ingress

3.定義遠程採集主機,(最多兩臺)

1)定義遠程IP地址,設備將抓過的數據包發向遠程主機(默認端口爲UDP 9991

R1(config)Ip flow-export destination 10.1.1.2 90

(2)配置數據包源地址

R1(config)# ip flow-export source f0/0

4.定義Netflow版本

1)全局定義Netflow版本(默認版本1,不一樣IOS支持的版本不一樣)

r1(config)#Ip flow-export ver 5

5.查看效果:

1)在r2ping R320.1.1.3

r2#ping 20.1.1.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 20.1.1.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/5/12 ms

r2#

(2)R1上查看記錄:

r1#sh ip cache flow

IP packet size distribution (10 total packets):

1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480

.000 .000 .000 1.00 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000

512 544 576 1024 1536 2048 2560 3072 3584 4096 4608

.000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000

IP Flow Switching Cache, 278544 bytes

2 active, 4094 inactive, 2 added

6 ager polls, 0 flow alloc failures

Active flows timeout in 30 minutes

Inactive flows timeout in 15 seconds

last clearing of statistics never

Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)

-------- Flows /Sec /Flow /Pkt /Sec /Flow /Flow

SrcIf SrcIPaddress DstIf DstIPaddress Pr SrcP DstP Pkts

Fa0/0 10.1.1.2 Fa0/1 20.1.1.3 01 0000 0800 5

Fa0/1 20.1.1.3 Fa0/0 10.1.1.2 01 0000 0000 5

說明:從以上結果能夠看出,擁有很詳細的數據包記錄。

3)查看更詳細

r1#sh ip cache verbose flow

IP packet size distribution (10 total packets):

1-32 64 96 128 160 192 224 256 288 320 352 384 416 448 480

.000 .000 .000 1.00 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000

512 544 576 1024 1536 2048 2560 3072 3584 4096 4608

.000 .000 .000 .000 .000 .000 .000 .000 .000 .000 .000

IP Flow Switching Cache, 278544 bytes

0 active, 4096 inactive, 2 added

32 ager polls, 0 flow alloc failures

Active flows timeout in 30 minutes

Inactive flows timeout in 15 seconds

last clearing of statistics never

Protocol Total Flows Packets Bytes Packets Active(Sec) Idle(Sec)

-------- Flows /Sec /Flow /Pkt /Sec /Flow /Flow

ICMP 2 0.0 5 100 0.0 0.0 15.0

Total: 2 0.0 5 100 0.0 0.0 15.0

SrcIf SrcIPaddress DstIf DstIPaddress Pr TOS Flgs Pkts

Port Msk AS Port Msk AS NextHop B/Pk Active

r1#

而且看到協議也有所記錄。

(4).可清除總記錄

R1#clear ip flow stats

6.聚合參數

說明:能夠將數據包中某些須要的數據聚合後顯示,好比BGP AS號碼,或者前綴等信息

1)配置聚合BGP AS(事先配好BGP

r1(config)#ip flow-aggregation cache as 進入聚合配置模式

r1(config-flow-cache)#cache entries 2000 配置可聚合的最多條目

r1(config-flow-cache)#cache timeout inactive 200 配置不活動會話的超時時間

r1(config-flow-cache)#cache timeout active 50 配置活動會話的時間

r1(config-flow-cache)#enabled 開啓

2)配置記錄中Origin-as 在源和目的中包含as

R1(config)#ip flow-export version 5 peer-as

7.查看結果:

(1)R2 ping r3

R2#ping 20.1.1.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 20.1.1.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms

R2#

2)查看記錄:

r1#sh ip cache flow aggregation as

IP Flow Switching Cache, 132104 bytes

4 active, 1996 inactive, 4 added

398 ager polls, 0 flow alloc failures

Active flows timeout in 50 minutes

Inactive flows timeout in 200 seconds

Src If Src AS Dst If Dst AS Flows Pkts B/Pk Active

Fa0/1 30 Fa0/0 0 1 10 100 0.9

Fa0/0 0 Fa0/1 30 1 10 100 0.9

r1#

說明:能夠看到擁有的AS記錄狀況。

注:cisco支持netflow設備通常路由器都支持

    4500系列須要引擎支持

    6500系列之後都支持netflow

    3750系列和3560系列不支持netflow

相關文章
相關標籤/搜索