IOS和IOS XE的速率限制配置翻译

 Committed Access Rate(CAR)承诺访问率

要处理其他类型的流量,包括ICMP不可达,可以使用承诺访问速率(CAR)。 CAR使您可以限制进入或离开接口的流量,并且可以根据以下任一条件进行匹配:所有IP流量,IP优先级值,MAC地址或与标准或扩展ACL中的许可声明匹配的信息。
CAR通常是在网络外围实现出口流量,它使您可以针对不同类型的流量采用不同的速率限制策略。 例如,与到Web服务器的HTTP流量相比,您对ICMP流量的速率限制可能有所不同。

警告:
使用ACL指定匹配的流量可能会占用大量的资源。 另外,如果您指定了多个策略,则路由器将受到额外的CPU利用率影响; 尝试限制您定义的策略数量。 由于这些问题,您应谨慎使用CAR。 通常,当我知道自己受到攻击并想要一种快速且肮脏的解决方案以在为有效用户和连接提供所需带宽的同时,防止不必要的流量时,我会使用CAR。 缓解攻击后,我删除了CAR配置。

CAR配置
这里重点介绍使用CAR处理DoS流量。 以下是设置CAR的命令:

outer(config-if)# interface type [slot_#]port_#
Router(config-if)# rate-limit {input | output} [access-group [rate-limit] acl-index] bps burst_normal burst_max conform-action action exceed-action action

 通过使用以下三个相应命令之一,使用速率限制,标准或扩展ACL匹配流量以进行速率限制:

Router(config-if)# access-list rate-limit ACL_# {precedence_value |  MAC_address | mask precedence_mask}

Router(config-if)# access-list ACL_# {deny | permit} source_IP_address [source-wildcard_mask]

Router(config-if)# access-list ACL_# {deny | permit} protocol source source_wildcard destination destination-wildcard [precedence precedence][tos tos] [log]

注意:CAR要求首先在路由器上启用CEF

限速命令rate-limit
使用rate-limit命令在路由器的接口上完成CAR的配置。 此命令指定用于匹配流量的速率策略。 输入input和输出output参数指定应执行CAR的方向。

速率参数
CAR配置中定义了三个速率参数:

  1. 匹配流量的平均速率average rate,以每秒bit位数(bps)指定。 这是通过接口上流量传输速率的长期平均值来衡量的。 低于此速率的流量被认为是符合要求的
  2. 正常突发大小normal burst,以每秒bit位数(bps)为单位指定。 这确定流量在被认为不合格之前可以突发超过平均速率
  3. 过多的突发速率excessive burst rate,以每秒位数(bps)为单位指定。 超过过量突发速率的流量被认为是不合格的
Rate Parameters
Three rate functions are defined in your CAR configuration:

The average rate, specified in bits per second (bps), for the matching traffic. This is measured by a long-term average of the transmitted rate of traffic on the interface. Traffic under this rate is considered to be conforming.

The normal burst size, specified in bits per second (bps). This determines how long traffic can burst above the average rate before it is considered nonconforming.

The excessive burst rate, specified in bits per second (bps). Traffic that exceeds the excessive burst rate is considered nonconforming.

从这些速率参数可以看出,这类似于帧中继的流量整形参数。 但是,关于帧中继的参数的重要一点是它们用于流量整形:CAR的参数用于速率限制。

conforming (conform-action parameter) or nonconforming (exceed-action parameter) traffic:

通常,您使用continue,transmission和set参数来使流量符合要求。 您使用drop命令处理不符合标准的流量。 请记住,在这种情况下,您正在使用CAR来限制DoS攻击的影响。 设置优先级值的选项可以在该接口上的其他CAR速率限制命令中使用,也可以在此路由器或其他路由器上的其他接口中使用。

验证CAR
设置CAR之后,可以使用以下三个命令之一来验证其操作:

Router# show access-lists
Router# show access-lists rate-limit [ACL_#]
Router# show interfaces [interface_type_and_#] rate-limit

示例

Router# show interfaces ethernet2/0 rate-limit
Ethernet2/0
 Input
 matches: access-group rate-limit 100
  params: 64000 bps, 8000 limit, 8000 extended limit
  conformed 0 packets, 0 bytes; action: transmit
  exceeded 0 packets, 0 bytes; action: drop
  last packet: 9383444ms ago, current burst: 0 bytes
  last cleared 01:32:00 ago, conformed 0 bps, exceeded 0 bps

在此示例中,ACL 100用于定义速率限制的流量。 平均速率为64,000 bps,两个突发大小设置为8,000 bps,从而限制了ACL 100中allow语句中指定的流量的突发。

Refer to:Cisco Router Firewall Security: DoS Protection

配置翻译

在目前的网络环境中,IOS的设备逐步将被IOS XE设备代理,关于CAR这部分的配置格式也发生了变化,IOS XE需要使用Class-map和Policy-map来进行配置。

1、IOS配置示例:

R10(config)#time-range T
R10(config-time-range)#periodic weekdays 9:00 to 17:00

R10(config)#access-list 166 permit ip any any time-range T

R10(config)#int e0/3
R10(config-if)#rate-limit output access-group 166 1000000 62500 62500 conform-action transmit exceed-action drop

查看参数配置:

R10#show interfaces ethernet 0/3 rate-limit
Ethernet0/3
  Output
    matches: access-group 166
      params:  1000000 bps, 62500 limit, 62500 extended limit
      conformed 0 packets, 0 bytes; action: transmit
      exceeded 0 packets, 0 bytes; action: drop
      last packet: 3935390ms ago, current burst: 0 bytes
      last cleared 00:47:29 ago, conformed 0 bps, exceeded 0 bps

2、将IOS的配置迁移为IOS XE的配置(例如ISR4K等设备)

时间和ACL部分的定义配置可以不变,主要是策略参数的配置会发生格式上的差别。

CSR7(config)#time-range T
CSR7(config-time-range)#periodic weekdays 09:00 to 17:00

CSR7(config)#access-list 166 permit ip any any time-range T

CSR7(config)#class-map match-all CM
CSR7(config-cmap)#match access-group 166
CSR7(config-cmap)#exi

CSR7(config)#policy-map PM
CSR7(config-pmap)#class CM
CSR7(config-pmap-c)#police 1000000 62500 62500 //这部分配置也可以是cir 1000000,bc 62500,be 625000
CSR7(config-pmap-c-police)#conform-action transmit
CSR7(config-pmap-c-police)#exceed-action drop

CSR7(config-pmap-c-police)#?
QoS Class Police configuration commands:
  conform-action  action when rate is less than conform burst
  conform-color   conform color aware
  exceed-action   action when rate is within conform and conform + exceed burst
  exit            Exit from Police configuration mode
  no              Negate or set default values of a command
  violate-action  action when rate is greater than conform + exceed burst

CSR7(config)#int gi4
CSR7(config-if)#service-policy output PM
CSR7(config-if)#end
CSR7#

查看参数配置:

CSR7#show policy-map interface gigabitEthernet 4
 GigabitEthernet4

  Service-policy output: PM

    Class-map: CM (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0000 bps, drop rate 0000 bps
      Match: access-group 111
      police:
          cir 1000000 bps, bc 62500 bytes, be 62500 bytes
        conformed 0 packets, 0 bytes; actions:
          transmit
        exceeded 0 packets, 0 bytes; actions:
          drop
        violated 0 packets, 0 bytes; actions:
          drop
        conformed 0000 bps, exceeded 0000 bps, violated 0000 bps

    Class-map: class-default (match-any)
      0 packets, 0 bytes
      5 minute offered rate 0000 bps, drop rate 0000 bps
      Match: any
CSR7#
好好学习,天天向上!
原文地址:https://www.cnblogs.com/MomentsLee/p/14637883.html