更新时间:2023-12-08                  
                  
                  
  
  
  1NETFLOW配置命令
 
  1.1NETFLOW配置命令
 
   NETFLOW配置命令有: 
 
   • netflow enable 
 
   • netflow timeout inactive 
 
   • netflow export destination 
 
   • netflow export version 
 
   • netflow export template 
 
   • netflow export template options 
 
   • netflow {ingress | egress} {ipv4 | mac}  
 
   • netflow {ingress | egress} dscp_mask 
 
   1.1.1netflow enable 
 
   命令描述 
 
   netflow enable 
 
   no netflow enable 
 
   开启或关闭netflow功能。 
 
   参数 
 
   无 
 
   缺省 
 
   关闭 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   用于全局的开启Netflow功能。 
 
   示例 
 
   下面的命令将在全局配置模式下开启Netflow功能。 
 
   Switch# 
 
   Switch#config 
 
   Switch_config#netflow enable 
 
   Switch_config# 
 
   1.1.2netflow timeout inactive 
 
   命令描述 
 
   netflow timeout inactive time 修改inactive时间 
 
   no netflow timeout inactive 恢复为默认的inactive时间 
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  time   |  Inactive时间,范围:<10 - 600>,默认值15秒  | 
 
    
  
 
   
 
   缺省 
 
   15秒 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   一条流在设定的inactive时间之内没有收到新的报文,则该条流被定义为inactive,流的信息将被超时输出。 
 
   示例 
 
   下面的命令将在全局配置模式下设置流的inactive时间为10秒。 
 
   Switch# 
 
   Switch#config 
 
   Switch_config#netflow timeout inactive 10 
 
        Switch_config# 
 
   1.1.3netflow export destination 
 
   命令描述 
 
   netflow export destination A.B.C.D port  
 
   no netflow export destination 
 
   设置发送报文的目的ip和端口号 
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  A.B.C.D   |  目的ip地址  | 
 
     
     |  port   |  目的端口号  | 
 
    
  
 
   缺省 
 
   无 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   设置发送流记录报文的目的ip和端口号。该ip和端口号应该是发往NetFlow Analyzer软件的。 
 
   示例 
 
   下面在全局配置模式下设置发送流记录信息的ip地址和端口号 
 
   Switch #config 
 
   Switch_config#netflow export destination 90.0.0.56 9996 
 
   Switch_config# 
 
   1.1.4netflow export version 
 
   命令描述 
 
   netflow export version version 选择发送流记录报文的版本 
 
   参数 
 
   
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  version  |  版本信息,包括V1,V5,V9。  | 
 
    
  
 
   
 
   缺省 
 
   V5 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   无 
 
   示例 
 
   下面的命令在全局配置模式下配置发送报文的版本为V9: 
 
   Switch_config#netflow export version 9 
 
   Switch_config# 
 
   
 
   1.1.5netflow export template 
 
   命令描述 
 
   netflow export template [refresh-rate times | timeout-rate time ] 
 
   设置输出模板,对V9有效。 
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  times  |  发送模板报文间隔的报文数,times取值范围1-600,默认值20  | 
 
     
     |  time  |  发送模板报文的间隔时间。time取值范围1-3600(分钟,默认值30)  | 
 
    
  
 
   缺省 
 
   times默认值20; 
 
   time默认值30; 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   发送模板报文的间隔时间和间隔报文次数任何一个超过设定的数值时,都将发送模板报文。 
 
   示例 
 
   在全局配置模式下修改模板的发送间隔: 
 
   Switch_config# 
 
   Switch_config# netflow export template refresh-rate 10 
 
   Switch_config# netflow export template timeout-rate 5 
 
   Switch_config# 
 
   1.1.6netflow export template options 
 
   命令描述 
 
   netflow export template options [refresh-rate times | timeout-rate time | export-stats] 
 
   设置输出模板选项信息,对V9有效。 
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  export-stats  |  设置发送模板选项导出统计。  | 
 
     
     |  times  |  设置发送模板选项记录间隔的报文数目。times是间隔的报文数目,范围1-600,默认值20  | 
 
     
     |  time  |  设置发送模板选项记录的间隔时间。time是间隔时间,取值范围1-3600(分钟,默认值30)  | 
 
    
  
 
   缺省 
 
   times默认值20; 
 
   time默认值30; 
 
   命令模式 
 
   全局配置模式 
 
   使用说明 
 
   只有开启要发送的模板选项,才会发送模板选项报文,而模板报文只要开启了V9就会进行发送。发送模板选项报文的间隔时间和间隔报文次数任何一个超过设定的数值时,都将发送模板选项报文。 
 
   示例 
 
   在全局配置模式开启模板选项,并修改模板选项的发送间隔: 
 
   Switch_config# 
 
   Switch_config# netflow export template option export-stats 
 
   Switch_config# netflow export template option refresh-rate 10 
 
   Switch_config# netflow export template option timeout-rate 5 
 
   Switch_config# 
 
   
 
  1.1.7netflow {ingress | egress} {ipv4 | mac}  
 
   命令描述 
 
   netflow {ingress | egress} {ipv4 | mac } [limit limit-number | sampler sampler-number | dst_mask  A.B.C.D | src_mask  A.B.C.D] 
 
   no netflow {ingress | egress} 
 
   配置接口上的采样参数。 
 
   
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  ingress   |  Ingress开启进入方向的报文采样  | 
 
     
     |  egress  |  Egress开启出方向的报文采样  | 
 
     
     |  ipv4   |  pv4开启ip报文上采样  | 
 
     
     |  mac   |  Mac开启二层报文采样  | 
 
     
     |  limit limit-number  |  Limit设置端口能创建的流记录的最大数;limit-numbe范围1-8192,默认值8192  | 
 
     
     |  sampler sampler-number  |  Sampler设置端口采样间隔,sampler-number范围1-8192,默认值1  | 
 
     
     |  dst_mask  A.B.C.D  |  Dst-mask设置ip报文采样的目的地址掩码;默认掩码255.255.255.255  | 
 
     
     |  src_mask  A.B.C.D  |  Src-mask设置ip报文采样的源地址掩码;默认掩码255.255.255.255  | 
 
    
  
 
   
 
   缺省 
 
   limit-number默认值8192; 
 
   sampler-number默认值1; 
 
   A.B.C.D默认值255.255.255.255; 
 
   命令模式 
 
   端口配置模式 
 
   使用说明 
 
   IP掩码的配置是为了减少报文流的创建而把多条流聚合为一条流。 
 
   示例 
 
   在端口GigaEthernet 1/2上对入方向的ipv4和二层报文进行采样。 
 
   Switch_config_g1/2#netflow ingress ipv4 mac 
 
   Switch_config_g1/2# 
 
   1.1.8netflow {ingress | egress} dscp_mask 
 
   命令描述 
 
   netflow {ingress | egress} dscp_mask dscp_value mask 
 
   配置接口上采样报文的DSCP映射值。 
 
   参数 
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  dscp_value  |  DSCP值,1-64对应DSCP的值0-63  | 
 
     
     |  mask   |  DSCP的映射值,取值范围0-63  | 
 
    
  
 
   
 
   缺省 
 
   在缺省的情况下DSCP的映射值都为0。 
 
   命令模式 
 
   端口配置模式 
 
   使用说明 
 
   默认的情况下DSCP的映射值都是0,这时候的DSCP值不能作为区分流的关键字。配置DSCP映射值是为了将DSCP值作为区分流的关键字。可以将多个DSCP值映射到一个相同的值,这个映射值将做为一个区分流的关键字。配置的DSCP映射值只有在再次开启端口采样功能的时候才生效。 
 
   示例 
 
   在端口GigaEthernet 1/2 ingress方向上将DSCP值10-20映射为10,并将10作为区分流的关键字。 
 
   Switch_config_g1/2#netflow ingress dscp_mask 10-20 10 
 
   Switch_config_g1/2# 
 
   
 
  1.2NETFLOW显示命令
 
   NETFLOW显示命令有: 
 
   • show netflow interface 
 
   • show netflow export 
 
   • show netflow cache [ingress | egress] 
 
   1.2.1show netflow interface 
 
   命令描述 
 
   show netflow interface显示Netflow接口配置信息 
 
   参数  
 
             无 
 
   缺省  
 
   无 
 
   说明  
 
   显示Netflow接口配置信息 
 
   示例  
 
   Switch_config# show netflow interface 
 
   GigaEthernet2/1(IfIndex7) 
 
   netflow ingress ipv4 mac 
 
   netflow egress ipv4 mac 
 
   GigaEthernet2/2(IfIndex8) 
 
   GigaEthernet2/3(IfIndex9) 
 
   GigaEthernet2/4(IfIndex10) 
 
   GigaEthernet2/5(IfIndex11) 
 
   GigaEthernet2/6(IfIndex12) 
 
   GigaEthernet2/7(IfIndex13) 
 
   GigaEthernet2/8(IfIndex14) 
 
  1.2.2show netflow export
 
   命令描述 
 
   show netflow export 
 
   参数  
 
   缺省  
 
   无 
 
   说明  
 
   显示Netflow报文和流的统计信息 
 
   示例  
 
   Switch# show netflow export 
 
   Flow export version 9 is enabled 
 
   Template export information: 
 
     Template timeout = 1 
 
     Template refresh rate = 10 
 
   Exporting packets appended Option statistics 
 
   Option export information: 
 
     Option timeout = 30 
 
     Option refresh rate = 20 
 
   
 
     Exporting flows to 90.0.0.56 (9996) via UDP 
 
   279 flows exported in 145 UDP datagrams 
 
   0 export packets failed 
 
   Statistics in 0:01:08:15 since last clear ip flow stats 
 
   Switch# 
 
   1.2.3show netflow cache 
 
   命令描述 
 
   show netflow cache {ingress | egress} [detail | interface interface-name] 
 
   参数  
 
   
    
     
     |  参数  |  参数说明  | 
 
     
     |  ingress  |  显示入方向流记录  | 
 
     
     |  egress  |  显示出方向流记录  | 
 
     
     |  detail  |  显示流记录详细信息  | 
 
     
     |  interface interface-name  |  显示与端口相关的流记录,interface-name为端口名称  | 
 
    
  
 
   缺省  
 
   无 
 
   说明  
 
   查看Netflow流记录信息 
 
   示例  
 
   查看进入端口的报文流信息: 
 
   Switch_config#show netflow cache ingress  
 
   Session information table: 
 
   FType   Ifdx/D      P/E-T   SrcIP/SrcMac      DstIP/DstMac      Pkts    Bytes   Src/DstPort 
 
   L2      g2/1/in     2054    1111.1111.1111     FFFF.FFFF.FFFF   269     17216   0/0 
 
   IPV4    g2/1/in     6       90.0.0.56          90.0.0.100         269     12374   0/0 
 
   IPV4    g2/1/in     0       90.0.0.1           1.2.3.4            269     12374   0/0 
 
   Session number: 3 
 
   Switch _config# 
 
  1.3NETFLOW清除命令
 
   NETFLOW清除命令有: 
 
   • clear netflow stats  
 
  1.3.1clear netflow stats 
 
   命令描述 
 
   clear netflow stats  
 
   参数 
 
   无 
 
   缺省 
 
   无 
 
   使用说明 
 
   清除Netflow报文和流记录统计信息 
 
   命令模式 
 
   管理配置模式 
 
   示例 
 
   Switch# clear netflow stats