cisco6500交换机的netflow配置
·
Catalyst 6500/6000交换机netflow配置
本文档提供一个在6500交换机上配置netflow的实例 ,当6500在网络中作为一个核心设备时,有必要使用netflow来监控流经交换机的流量。
本文档的信息是基于以下软件和硬件版本:
· Catalyst 6500 with Supervisor Engine 32, MSFC2A and PFC3
· Catalyst 6500 that runs Cisco IOS® Software Release 12.2(18)SXF4
注意:netflow配置也支持Route Switch Processor 720, Supervisor Engine 720,配置在他们之间没有不同。
本文档中涉及的信息是基于特定的实验环境,所有使用的设备有一个默认的配置。
背景信息
Netflow是用于提供流经路由器的数据包的统计;
Netflow在全局状态下从流经交换机的流量中采集数据,之后将其储存在netflow table中,可以使用命令行进入netflow table,也可以输出netflow统计数据到一个report 服务器( netflow collector),此时需要在交换机上配置NDE。Netflow只监控在cef的流量,在接口配置下输入ip route-cache命令打开需要监控的接口。
在配置netflow之前有一下几点须知:
· 在MSFC卡上的netflow缓存获取在软件上的流量统计数据。
· 在PFC卡上的netflow缓存获取在硬件上的流量统计数据。
· 通过flow mask定义在netflow缓存表中的缓存条目。
o source-only—A less-specific flow mask,PFC为每个具有相同源ip地址的流量保持一个条目,所有具有这个相同源地址的流量使用这个条目。
o destination—A less-specific flow mask,PFC为每个具有相同目的ip地址的流量保持一个条目,所有具有这个相同目的地址的流量使用这个条目。
o destination-source—A more-specific flow mask.
o destination-source-interface—在destination-source flow mask基础上加入了源VLAN SNMP端口索引。
o full—A more-specific flow mask., PFC为每个IP流量创建并保持一个独立的缓存条目, 条目内容包括the source IP address, destination IP address, protocol, and protocol interfaces。
o full-interface
· 在PFC的NDE支持NDE版本5和7。
配置
实例指出如何在交换机上配置netflow,如何配置NDE用来输出netflow缓存到netflow collector。也讨论了netflow适合自身网络一些可选的参数,本例中,6500交换机有两个vlan,10和20,作为网络的内部,接口f3/1被连接到网络的外部。
在 Native IOS中配置
所有配置如下:
一: Enable NetFlow
在MSFC和PFC上enable NetFlow,下面的例子一步步指导如何enable netflow。
1.在PFC上Enable Netflow
2.在PFC上配置flow mask
3.在MSFC上Enable NetFlow
4.Enable NetFlow for Layer 2-switched traffic on the PFC (.在PFC上为2层交换流量打开netflow)
|
Switch
|
|
Switch(config-if)#ip address 10.10.10.1 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface Vlan20
Switch(config-if)#ip address 10.10.20.1 255.255.255.0
Switch(config-if)#exit
Switch(config)#interface loopback 0
Switch(config-if)#ip address 10.10.1.1 255.255.255.255
Switch(config-if)#exit
Switch(config)#interface fastEthernet 3/1
Switch(config-if)#no switchport
Switch(config-if)#ip address 10.10.200.1 255.255.255.0
Switch(config-if)#exit
!--- This configuration shows that
!--- the VLANs are configured with IP addresses.
switch(config)#mls flow ip full --- Configures flow mask on the PFC. In this example, flow mask is configured as full.
Switch(config-if)#ip route-cache flow
Switch(config-if)#exit
Switch(config)#interface Vlan20
Switch(config-if)#ip route-cache flow
Switch(config-if)#exit
Switch(config)#interface fastEthernet 3/1
Switch(config-if)#ip route-cache flow
Switch(config-if)#exit --- Enables NetFlow on the MSFC.
!--- It also enables the NDE for Layer 2-switched traffic on the PFC.
|
二:配置NDE
在交换机上通过 show mls netflow ip 命令查看活跃的netflow缓存。 当netflow缓存终止或者超出时,在命令行上不再看到netflow流量,这时可以输出期满的netflow缓存到netflow collector上。而如果要储存历史的netflow流量到collector中,就需要配置NDE。有许多netflow collector可用,包括cisco netflow collector和cisco-mars设备。
在PFC上配置NDE;在MSFC上配置NDE;在PFC上为2层交换流量打开NDE
|
Switch
|
|
!--- Configures NDE in the PFC. This example configures NDE version 5.
!--- You need to configure the version based on your NetFlow collector.
!--- The mls nde sender command configures
!--- the NDE with default version 7. If your NetFlow collector supports
!--- version 7 NDE format, you need to issue the
!--- mls nde sender command.
Switch(config)#ip flow-export destination 10.10.100.2 9996
!--- Configures NDE on the MSFC with the NetFlow collector IP address
!--- and the application port number 9996. This port number varies
!--- depending on the NetFlow collector you use.
Switch(config)#ip flow export layer2-switched vlan 10,20
!--- Enabling ip flow ingress as in the Enable NetFlow Section
!--- automatically enables ip flow export.
!--- If you disabled ip flow export earlier, you can enable it as mentioned.
--- Show run does not show the ip flow export command.
|
可选配置
· multilayer switching (MLS) aging
如果 netflow traffic 是活跃的, netflow 缓存不会期满。如果netflow缓存不期满,netflow缓存不输出到netflow collector。为了确保连续不断的活跃流量的输出,使用 mls aging long 命令(默认 32 分钟),下面的输出显示默认 MLS 缓时间间隔。
· asnml-c6509-01# show mls netflow aging
· enable timeout packet threshold
· ------ ------- ----------------
· normal aging true 300 N/A
· fast aging false 32 100
long aging true 1920 N/A
· NetFlow sampling (取样)
默认情况下, netflow 抓取流量中所有的包,当使用NetFlow sampling时,可以获取包的子集,NetFlow sampling可以基于时间,也可以基于数据包。
· NetFlow aggregation
汇总缓存是在交换机中另外的一个 netflow 缓存表,表中有 netflow 流量的总的流量统计。6500交换机Netflow汇总可以基于源前缀、目的前缀、协议号,可同时配置。Netflow汇总缓存可以减少交换机和netflow collector之间的带宽。
· NDE flow filters
可以配置 NDE 流量过滤来只输出感兴趣的 netflow 缓存,可基于源地址、目的地址、源端口和目的端口过滤 netflow 缓存条目
· NetFlow Cache Entries—You can increase or decrease number of NetFlow entries in the NetFlow cache.
在 netflow 缓存中可以增加或者减少 netflow 条目的数量
|
Switch
|
|
Switch(config)# mls aging long 300
!--- Configures the switch to delete the active NetFlow cache entries after 5 minutes. The default value is 32 minutes.
Switch(config)# mls aging normal 120
--- Configures the switch to delete the inactive NetFlow cache entries after 2 minutes. The default value is 5 minutes.
Switch(config)# mls sampling time-based 64
1 out of 64 packets is sampled for the NetFlow cache. By default,sampling is disabled and every packet is captured into the NetFlow cache.
Switch(config)# ip flow-aggregation cache protocol-port
Switch(config-flow-cache)# cache entries 1024
Switch(config-flow-cache)# cache timeout active 30
Switch(config-flow-cache)# cache timeout inactive 300
Switch(config-flow-cache)# export destination 10.10.100.2 9996
Switch(config-flow-cache)# enabled
Switch(config-flow-cache)# exit
!--- Configures protocol and port aggregation scheme.
Switch(config)# mls nde flow exclude protocol tcp dest-port 23
!--- Configures the NDE not to export the traffic with destination port tcp 23.
Switch(config)# ip flow-cache entries 128000
!--- The change in number of entries take effect after either the next reboot or when netflow is turned off on all interfaces.
|
|
分割活动期长的流为 1 分钟的片段。你可以选择 1 到 60 之间的任何分钟值。
如果使用缺省的 30 分钟,则流量报告也许会许多尖峰。
|
|
ip flow-cache timeout inactive 15
|
保证定期输出完成的流。缺省值为 15 秒,可以选择 10 到 600 之间的任何值。如果选择的值大于 250 秒。也许 NetFlow 分析仪将报告流量值太低的错误。
|
snmp-server ifindex persist
|
全局启用 ifIndex 持续化 ( 接口名 ) 。这将保证 ifIndex 值在设备重启后也有效。
|
检验
这里告诉我们如何检验查看netflow缓存表和NDE,同时提供一个取样netflow采集器。
show mls netflow ip 命令显示在引擎模块中的netflow缓存条目,这个是取样输出。
· Switch#show mls netflow ip
Displaying Netflow entries in Supervisor Earl
DstIP SrcIP Prot:SrcPort:DstPort Src i/f :AdjPtr
-----------------------------------------------------------------------------
Pkts Bytes Age LastSeen Attributes
---------------------------------------------------
10.10.10.100 10.10.10.1 tcp :telnet :2960 -- :0x0
26 1223 101 20:35:41 L2 - Dynamic
10.10.20.2 10.10.20.1 tcp :11837 :179 -- :0x0
6 315 174 20:35:29 L2 - Dynamic
10.10.200.1 10.10.200.2 tcp :21124 :179 -- :0x0
0 0 176 20:35:28 L3 - Dynamic
10.10.20.1 10.10.20.2 tcp :179 :11837 -- :0x0
0 0 174 20:35:29 L3 - Dynamic
171.68.222.140 10.10.10.100 udp :3046 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.10.10.100 64.101.128.56 udp :dns :2955 -- :0x0
6 944 178 20:34:29 L3 - Dynamic
10.10.200.2 10.10.200.1 tcp :179 :21124 -- :0x0
5 269 133 20:35:28 L2 - Dynamic
0.0.0.0 0.0.0.0 0 :0 :0 -- :0x0
87 10488 133 20:35:29 L3 - Dynamic
171.68.222.136 10.10.10.100 udp :3047 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.10.10.100 171.70.144.201 icmp:0 :0 -- :0x0
1 60 71 20:34:30 L3 - Dynamic
171.68.222.140 10.10.10.100 udp :3045 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.10.10.100 64.101.128.92 tcp :3128 :2993 -- :0x0
20 13256 102 20:34:00 L3 - Dynamic
10.10.10.100 171.68.222.140 udp :1029 :3045 -- :0x0
1 368 2 20:35:39 L3 - Dynamic
171.68.222.140 10.10.10.100 icmp:771 :0 -- :0x0
1 176 2 20:35:39 L3 - Dynamic
10.10.10.100 10.16.151.97 udp :1029 :3048 -- :0x0
1 366 2 20:35:39 L3 - Dynamic
10.16.151.97 10.10.10.100 udp :3045 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
171.68.222.136 10.10.10.100 udp :3049 :1029 -- :0x0
2 152 2 20:35:39 L3 - Dynamic
171.68.222.136 10.10.10.100 udp :3045 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
64.101.128.56 10.10.10.100 udp :2955 :dns -- :0x0
6 389 178 20:34:29 L3 - Dynamic
10.10.10.100 171.68.222.136 udp :1029 :3045 -- :0x0
1 366 2 20:35:39 L3 - Dynamic
171.68.222.136 10.10.10.100 udp :3050 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.16.151.97 10.10.10.100 udp :3048 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.10.10.100 64.101.128.92 tcp :3128 :2991 -- :0x0
15 4889 106 20:34:00 L3 - Dynamic
10.10.10.100 10.16.151.97 udp :1029 :3045 -- :0x0
1 366 2 20:35:39 L3 - Dynamic
171.68.222.140 10.10.10.100 udp :3051 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.16.151.97 10.10.10.100 icmp:771 :0 -- :0x0
1 176 2 20:35:39 L3 - Dynamic
10.10.10.100 64.101.128.92 tcp :3128 :2992 -- :0x0
16 7019 106 20:34:00 L3 - Dynamic
10.10.10.100 171.68.222.136 udp :1029 :3047 -- :0x0
1 366 2 20:35:39 L3 - Dynamic
10.16.151.97 10.10.10.100 udp :3052 :1029 -- :0x0
1 46 2 20:35:39 L3 - Dynamic
10.10.10.100 171.68.222.140 udp :1029 :3046 -- :0x0
1 368 2 20:35:39 L3 - Dynamic
10.10.10.1 10.10.10.100 tcp :2960 :telnet -- :0x0
0 0 101 20:35:41 L3 - Dynamic
10.10.10.100 171.68.222.136 udp :1029 :3049 -- :0x0
2 961 2 20:35:39 L3 - Dynamic
171.68.222.136 10.10.10.100 udp :3053 :1029 -- :0x0
2 152 2 20:35:40 L3 - Dynamic
10.10.10.100 171.68.222.136 udp :1029 :3050 -- :0x0
1 366 2 20:35:39 L3 - Dynamic
10.10.10.100 171.68.222.136 udp :1029 :3053 -- :0x0
2 961 1 20:35:40 L3 - Dynamic
10.10.10.100 171.68.222.140 udp :1029 :3051 -- :0x0
在生产环境中,这个输出是巨大的,在这个命令下有可选项,通过?显示感兴趣的流量。
count total number of mls entries
destination show entries with destination ip address
detail display additional per-flow detail
dynamic hardware created netflow statistics entries
flow flow
module Show for module
nowrap no text wrap
qos qos statistics
source show entries with source ip address
sw-installed s/w installed netflow entries
| Output modifiers
<cr>
show mls nde 命令显示 netflow 输出信息,这个信息显示输出的 netflow 采集器和输出的包的数量,这是个取样输出。
Netflow Data Export enabled
Exporting flows to 10.10.100.2 (9996)
Exporting flows from 10.10.1.1 (52039)
Version: 5
Layer2 flow creation is enabled on vlan 10,20
Layer2 flow export is enabled on vlan 10,20
Include Filter not configured
Exclude Filter not configured
Total Netflow Data Export Packets are:
337 packets, 0 no packets, 3304 records
Total Netflow Data Export Send Errors:
IPWRITE_NO_FIB = 0
IPWRITE_ADJ_FAILED = 0
IPWRITE_PROCESS = 0
IPWRITE_ENQUEUE_FAILED = 0
IPWRITE_IPC_FAILED = 0
IPWRITE_OUTPUT_FAILED = 0
IPWRITE_MTU_FAILED = 0
IPWRITE_ENCAPFIX_FAILED = 0
Netflow Aggregation Disabled
|
显示当前 Netflow 的配置。
|
|
|
show ip cache flow
|
该命令显示当前活动的流的概要,还显示设备输出了多少 Netflow 数据。
|
show ip cache verbose flow
|
clear mls nde flow counters 命令是为了清除 NDE 数据。
· 下面的图标显示来自collector的一个取样输出
这个章节提供对所作配置进行troubleshooting。
1. 首先必须在MSFC三层接口上打开netflow,配置使其在PFC和MSFC卡上支持NDE,如果不需要2层桥接流量,可以 no ip flow ingress layer2-switched ,关闭其功能。
2. 如果已经配置flow masks为full或者interface-full,就不能在配置NAT接口上打开netflow。在接口上打开NAT命令为ip nat inside 或者 ip nat outside。同时配置的话会报错,显示如下信息:
3. PFC3和PFC2在硬件上不使用netflow表做三层交换。
4. Netflow汇总使用NDE版本8,使用时保证netflow采集器支持版本8.
5.. 当同时在SVI接口使用 ip flow ingress 和 ip flow egress 时,会导致接受完全一样的数据包,一般情况,只在入口或者出口配置 netflow , 因为netflow工作在一对接口基础上。
注意:cisco软件版本12.2(33)SXH或者更高的版本支持每个接口上NDE
5. netflow必须在本地路由器上enable,为了执行2层分析。
After you enable NetFlow, the show mls netflow ip command shows only the traffic in a single direction. By default, NetFlow caches only the ingress traffic. Issue the ip route-cache flow command on both the inbound and outbound interfaces in order to cache both inbound and outbound traffic.
在开启netflow功能后, show mls netflow ip 命令仅显示单方向的流量,默认 netflow 缓存入方向的流量, 同时在入口和出口使用 ip route-cache flow 命令可以存储进和出的流量
默认,netflow不显示穿过相同vlan的流量统计,只显示从一个vlan到另一个vlan的流量。
注意:为了查看穿过相同vlan的流量统计,关闭软件交换netflow,例如,不配置 ip route-cache flow 在三层接口上。
为了打开在一个特定vlan的交换、桥接2层IP流量,配置 ip flow layer2-switched 命令。
下面是ip流量不显示源和目的IP地址的原因:
· 数据包被ACL阻拦
· 数据包被交换处理
· 多播流量
· 以路由为目的的数据包
· Tunnels (IPIP, GRE, IPSEC, L2TP) & WCCP
· Static route to null0
· DstIf is NULL when the traffic is dropped because of CAR.
转载于:https://blog.51cto.com/nalushenxian/579782
更多推荐





所有评论(0)