Chinaunix首页 | 论坛 | 博客

qsh

  • 博客访问: 3943703
  • 博文数量: 1015
  • 博客积分: 15904
  • 博客等级: 上将
  • 技术积分: 8572
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-04 19:16
文章分类

全部博文(1015)

文章存档

2019年(1)

2017年(1)

2016年(19)

2015年(27)

2014年(30)

2013年(95)

2012年(199)

2011年(72)

2010年(109)

2009年(166)

2008年(296)

分类: 系统运维

2012-07-19 16:32:58

概述

在需要对Cisco设备上查看数据的流量传输情况的时候,我们可以用到的技术是IP Accounting,但是可以看出这个技术记录出的流量是非常简洁的,只能看到数据包的量,却看不到数据包的协议。下面有一项技术在IP Accounting的基础上增加了一些有用的附加功能,它不仅能记录数据的数量,并且还可以记录出协议等信息,这就是NetFlow

Cisco开发的NetFlow4个版本,分别是ver 1 ver 5ver 8ver 9,它们的特点是:

V9不向后兼容v8v5,需要独立开启。

V8只支持聚合缓存,不支持新feature

V5只支持主缓存,不支持新feature

V1,不要使用,建议用59

在网络设备上抓包,在每台设备上独立进行,不需要所有设备开启。

配置Netflow的条件:

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记录情况。

 

阅读(3539) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~