示例:配置分层监管器以限制静态环境中的服务速率
此示例说明如何配置分层监管器并将监管器应用于 MX 系列路由器上逻辑接口上的入口第 2 层 流量。
要求
在开始之前,请确保您的环境满足以下要求:
应用分层监管器的接口是托管在 MX 系列路由器上的接口。
不会将其他监管器应用于应用分层监管器的接口的输入。
您知道,如果将分层监管器应用于同时应用了输入过滤器的逻辑接口,则首先执行监管器。
概述
在此示例中,您将配置分层监管器并将该监管器应用于逻辑接口上的入口第 2 层 流量。 表 1 介绍了可在逻辑接口和物理接口上配置和应用分层监管器的层次结构级别。
监管器配置 |
第 2 层 应用 |
要点 |
---|---|---|
分层监管器
对所有协议系列的 2 层 入口流量进行分层速率限制。不能应用于出口流量、第 3 层 流量或接口层次结构的特定协议级别。在 MX 系列路由器的密集端口集中器 (DPC) 上的接口上受支持。 |
||
分层监管器的聚合和高级监管组件: [edit dynamic-profiles profile-name firewall] hierarchical-policer policer-name { aggregate { if-exceeding { bandwidth-limit bps; burst-size-limit bytes; } then { discard; forwarding-class class-name; loss-priority supported-value; } } premium { if-exceeding { bandwidth-limit bps; burst-size-limit bytes; } then { discard; } } } |
选项 A(物理接口)— 直接应用于物理接口上的第 2 层 输入流量: [edit dynamic-profiles profile-name interfaces] interface-name { layer2-policer { input-hierarchical-policer policer-name; } } |
物理接口上配置的所有协议家族和逻辑接口的分层速率限制第 2 层 入口流量。
注意:
如果在物理接口上应用分层监管器,则不能同时将分层监管器应用于任何成员逻辑接口。 |
选项 B(逻辑接口)— 直接应用于逻辑接口上的第 2 层 输入流量: [edit dynamic-profiles profile-name interfaces] interface-name { unit unit-number { layer2-policer { input-hierarchical-policer policer-name; } } } |
针对特定逻辑接口上配置的所有协议家族的分层速率限制第 2 层 入口流量。
注意:
您必须为逻辑接口配置至少一个协议族。 |
您可以将监管器应用于为 IPv4 流量配置的千兆以太网逻辑接口 ge-1/2/0.0。将分层监管器应用于逻辑接口时,IPv4 流量将受到分层速率限制。如果选择将分层监管器应用于物理接口 ge-1/2/0,则分层监管也适用于通过逻辑接口的 IPv4 流量。
配置
以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅 在配置模式下使用 CLI 编辑器。
要配置此示例,请执行以下操作:
CLI 快速配置
要快速配置此示例,请将以下配置命令复制到文本文件中,删除所有换行符,然后将命令粘贴到层次结构级别的 CLI [edit]
中。
set dynamic-profiles basic-profile set dynamic-profiles basic-profile interfaces “$junos-interface-ifd-name” set dynamic-profiles basic-profile interfaces "$junos-interface-ifd-name" unit “$junos-underlying-interface-unit” set dynamic-profiles basic-profile interfaces "$junos-interface-ifd-name" unit $junos-underlying-interface-unit family inet set dynamic-profiles interfaces ge-1/2/0 unit 0 family inet address 203.0.113.80/31 set dynamic-profiles basic-profile firewall family inet filter hierarch-filter set dynamic-profiles basic-profile firewall family inet filter hierarch-filter interface-specific set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1 set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip2 set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1 from precedence critical-ecp protocol set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1 from protocol tcp set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1 then hierarchical-policer hp1-share filter-specific set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip2 from precedence internet-control set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip2 from protocol tcp set dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip2 then hierarchical-policer hp2-share set class-of-service forwarding-classes class fc0 queue-num 0 priority high policing-priority premium set class-of-service forwarding-classes class fc1 queue-num 1 priority low policing-priority normal set class-of-service forwarding-classes class fc2 queue-num 2 priority low policing-priority normal set class-of-service forwarding-classes class fc3 queue-num 3 priority low policing-priority normal set dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem aggregate if-exceeding bandwidth-limit 10m burst-size-limit 100k set dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem aggregate then forwarding-class fc1 set dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem premium if-exceeding bandwidth-limit 2m burst-size-limit 50k set dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem premium then discard set dynamic-profiles basic-profile interfaces ge-1/2/0 unit 0 layer2-policer input-hierarchical-policer policer-agg-prem
为订阅者管理配置基本动态配置文件
分步过程
动态配置文件是在模板类型中定义的一组特征,可用于为宽带应用程序提供动态订阅者访问和服务。这些服务是动态分配给接口的。基本概要文件必须包含概要文件名称,并且在层次结构级别包含接口变量名称(如$junos-interface-ifd-name),在层次结构级别包含[edit dynamic-profiles profile-name interfaces
[edit dynamic-profiles profile-name interfaces variable-interface-name unit]
逻辑接口变量名称(如$junos-underlying-interface-unit或$junos-interface-unit)。
创建新的动态配置文件。
[edit] user@host# set dynamic-profiles basic-profile
interface-name
使用路由器用于匹配接收接口的接口名称的内部变量定义$junos-interface-ifd-name变量语句。[edit dynamic-profiles basic-profile] user@host# set interfaces “$junos-interface-ifd-name”
variable-interface-name unit
使用内部变量定义语句。引用现有接口时,请指定 $junos-underlying-interface-unit 路由器使用的变量以匹配接收接口的单位值。
创建动态接口时,请指定 $junos-interface-unit 路由器用于为接口生成单位值的变量。
[edit dynamic-profiles basic-profile interfaces "$junos-interface-ifd-name"] user@host# set unit $junos-underlying-interface-unit
或
[edit dynamic-profiles basic-profile interfaces "$junos-interface-ifd-name"] user@host# set unit $junos-interface-unit
定义变量的 $junos-interface-unit 家族地址类型(对于 IPv4,inet 表示)。
[edit dynamic-profiles basic-profile interfaces "$junos-interface-ifd-name" unit $junos-underlying-interface-unit] user@host# set family inet
结果
通过输入 show dynamic-profiles
配置命令确认动态配置文件的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show dynamic-profiles dynamic-profiles { basic-profile { interfaces { "$junos-interface-ifd-name" { unit "$junos-underlying-interface-unit" { family inet; } } } } }
如果完成设备配置,请从配置模式输入 commit
。
配置接口
分步过程
为此分层监管器示例定义物理和逻辑接口。
配置物理接口。
[edit dynamic-profiles basic-profile] user@host# set interfaces ge-1/2/0
使用其 IPv4 (inet) 协议家族接口将逻辑接口配置为单元 0。
[edit dynamic-profiles basic-profile interfaces ge-1/2/0] user@host# set unit 0 family inet address 203.0.113.80/31
注意:如果将第 2 层监管器应用于此逻辑接口,则必须至少配置一个协议家族。
结果
输入配置命令确认 show dynamic-profiles basic-profile interfaces
配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show dynamic-profiles basic-profile interfaces ge-1/2/0 { unit 0 { family inet { address 203.0.113.80/31; } } }
配置防火墙过滤器
分步过程
要将分层监管器配置为过滤器操作,必须先配置防火墙过滤器。
配置防火墙过滤器的家族地址类型(对于 IPv4 为 inet)并指定过滤器名称。
建议将筛选器命名为指示筛选器用途的名称。
[edit dynamic-profiles basic-profile] user@host# set firewall family inet filter hierarch-filter
要覆盖计数器和监管操作的聚合,并使每个计数器或策略功能特定于每个接口应用程序,
interface-specific
请在过滤器中包含该语句。[edit dynamic-profiles basic-profile firewall family inet filter hierarch-filter] user@host# set interface-specific
指定筛选器的术语名称。
使每个术语名称唯一并表示其功能。
[edit dynamic-profiles basic-profile firewall family inet filter hierarch-filter] user@host# set term match-ip1 user@host# set term match-ip2
在每个防火墙过滤器术语中,指定用于匹配数据包组件的条件。
配置第一个术语以将通过 TCP 接收的 IPv4 数据包与 IP 优先级字段关键 ecp (0xa0) 协议进行匹配,并将分层监管器应用为过滤器操作。
[edit dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1] user@host# set from precedence critical-ecp protocol user@host# set from protocol tcp
指定当数据包与第一个术语中的所有条件匹配时要执行的操作。启用一个过滤器中的所有分层监管器,以共享数据包转发引擎中的同一监管器实例。
[edit dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip1] user@host# set then hierarchical-policer hp1-share filter-specific
配置第二个术语以将通过 TCP 接收的 IPv4 数据包与 IP 优先级字段互联网控制 (0xc0) 匹配,并将分层监管器应用为过滤器操作。
[edit dynamic-profiles basic-profile firewall family inet filter hierarch-filter term match-ip2] user@host# set from precedence internet-control user@host# set from protocol tcp
指定当数据包与第二个术语中的所有条件匹配时要执行的操作。
[edit dynamic-profiles basic-profile firewall family inet filter inet-filter term match-ip2] user@host# set then hierarchical-policer hp2-share
结果
输入配置命令确认 show dynamic-profiles basic-profile firewall
配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show dynamic-profiles basic-profile firewall family inet { filter hierarch-filter { interface-specific; term match-ip1 { from { precedence critical-ecp protocol; protocol tcp; } then hierarchical-policer hp1-share; } term match-ip2 { from { precedence internet-control; protocol tcp; } then hierarchical-policer hp2-share; } } }
配置转发类
分步过程
定义作为聚合监管器操作引用的转发类。要使分层监管器正常工作,必须将入口流量正确分类为高级存储桶和非高级存储桶。需要某些服务等级 (CoS) 配置,因为分层监管器必须能够将高级/加速转发 (EF) 流量与非高级/非 EF 流量分开。
启用转发类的配置。
[edit] user@host# set class-of-service forwarding-classes
定义 CoS 转发类,以包括指定哪个转发类是高级的。这默认为与 EF 流量关联的转发类。
[edit class-of-service forwarding-classes] user@host# set class fc0 queue-num 0 priority high policing-priority premium user@host# set class fc1 queue-num 1 priority low policing-priority normal user@host# set class fc2 queue-num 2 priority low policing-priority normal user@host# set class fc3 queue-num 3 priority low policing-priority normal
结果
输入 show class-of-service
配置命令,确认作为聚合监管器操作引用的转发类的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show class-of-service forwarding-classes { class fc0 queue-num 0 priority high policing-priority premium; class fc1 queue-num 1 priority low policing-priority normal; class fc2 queue-num 2 priority low policing-priority normal; class fc3 queue-num 3 priority low policing-priority normal; }
配置分层监管器
分步过程
配置分层监管器的聚合和高级监管组件。
启用分层监管器的配置。
[edit dynamic-profiles basic-profile] user@host# set firewall hierarchical-policer policer-agg-prem
将聚合监管器配置为将带宽限制设置为 10 Mbps,将突发大小限制设置为 100 KB,并将不合格操作设置为将转发类更改为 fc1。
[edit dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem] user@host# set aggregate if-exceeding bandwidth-limit 10m burst-size-limit 100k user@host# set aggregate then forwarding-class fc1
注意:对于聚合监管器,不合格流中数据包的可配置操作是丢弃数据包、更改丢失优先级或更改转发类。
将高级监管器配置为将带宽限制设置为 2 Mbps,将突发大小限制设置为 50 KB,并将不合格操作设置为丢弃数据包。
[edit dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem] user@host# set premium if-exceeding bandwidth-limit 2m burst-size-limit 50k user@host# set premium then discard
注意:高级监管器的带宽限制不得大于聚合监管器的 带宽限制。对于高级监管器,对于不合格流量中的数据包,唯一可配置的操作是丢弃数据包。
结果
输入 show dynamic-profiles basic-profile firewall
配置命令,确认分层监管器的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show dynamic-profiles basic-profile firewall hierarchical-policer policer-agg-prem { aggregate { if-exceeding { bandwidth-limit 10m; burst-size-limit 100k; } then { forwarding-class fc1; } } premium { if-exceeding { bandwidth-limit 2m; burst-size-limit 50k; } then { discard; } } }
将分层监管器应用于物理或逻辑接口上的第 2 层入口流量
分步过程
您可以将监管器直接应用于接口或通过过滤器应用,以仅影响匹配的流量。在大多数情况下,您可以在入口、出口或两个方向调用监管功能。
对于物理接口,分层监管器使用单个监管器实例对物理接口上配置的所有逻辑接口和协议家族进行速率限制,即使这些逻辑接口具有互斥系列(如 inet 或网桥)也是如此。
对于逻辑接口,分层监管器可以监管来自多个协议家族的流量,而无需在逻辑接口上为每个此类家族单独实例化监管器。
要对逻辑接口 ge-1/2/0.0 上的 IPv4 流量的第 2 层 入口流量进行分层速率限制,请从逻辑接口配置中引用监管器。
配置逻辑接口。
[edit dynamic-profiles basic-profile] user@host# set interfaces ge-1/2/0 unit 0
将监管器应用于逻辑接口上的第 2 层 流量时,必须为逻辑接口定义至少一个协议族。
将监管器应用于逻辑接口。
[edit dynamic-profiles basic-profile interfaces ge-1/2/0 unit 0] user@host# set layer2-policer input-hierarchical-policer policer-agg-prem
或者,要对所有协议家族和物理接口 ge-1/2/0 上配置 的所有逻辑 接口的第 2 层 入口流量进行分层速率限制,请从物理接口配置中引用监管器。
结果
输入 show dynamic-profiles basic-profile interfaces
配置命令,确认分层监管器的配置。如果命令输出未显示预期的配置,请重复此过程中的说明以更正配置。
[edit] user@host# show dynamic-profiles basic-profile interfaces ge-1/2/0 { unit 0 { layer2-policer { input-hierarchical-policer policer-agg-prem; } family inet { address 203.0.113.80/31; } } }
验证
确认配置工作正常。
显示接口的流量统计信息
目的
验证通过物理接口的流量。
行动
show interfaces
对物理接口 ge-1/2/0 使用操作模式命令,并包括detail
或extensive
选项。
user@host> show interfaces ge-1/2/0 extensive Physical interface: ge-1/2/0, Enabled, Physical link is Down Interface index: 156, SNMP ifIndex: 630, Generation: 159 Link-level type: Ethernet, MTU: 1514, MRU: 1522, Speed: 1000mbps, BPDU Error: None, MAC-REWRITE Error: None, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Pad to minimum frame size: Disabled Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x4000 Link flags : None CoS queues : 8 supported, 8 maximum usable queues Schedulers : 0 Hold-times : Up 0 ms, Down 0 ms Current address: 00:00:5E:00:53:4c, Hardware address: 00:00:5E:00:53:4c Last flapped : 2014-11-10 13:36:25 EST (01:26:30 ago) Statistics last cleared: Never Traffic statistics: Input bytes : 0 0 bps Output bytes : 42 0 bps Input packets: 0 0 pps Output packets: 1 0 pps IPv6 transit statistics: Input bytes : 0 Output bytes : 0 Input packets: 0 Output packets: 0 Dropped traffic statistics due to STP State: Input bytes : 0 Output bytes : 0 Input packets: 0 Output packets: 0 Input errors: Errors: 0, Drops: 0, Framing errors: 0, Runts: 0, Policed discards: 0, L3 incompletes: 0, L2 channel errors: 0, L2 mismatch timeouts: 0, FIFO errors: 0, Resource errors: 0 Output errors: Carrier transitions: 0, Errors: 0, Drops: 0, Collisions: 0, Aged packets: 0, FIFO errors: 0, HS link CRC errors: 0, MTU errors: 0, Resource errors: 0 Egress queues: 8 supported, 8 in use Queue counters: Queued packets Transmitted packets Dropped packets 0 0 0 0 1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 6 0 0 0 7 0 0 0 Queue number: Mapped forwarding classes 0 best-effort 1 expedited-forwarding 2 assured-forwarding 3 network-control 4 be1 5 ef1 6 af1 7 nc1 Active alarms : LINK Active defects : LINK MAC statistics: Receive Transmit Total octets 0 0 Total packets 0 0 Unicast packets 0 0 Broadcast packets 0 0 Multicast packets 0 0 CRC/Align errors 0 0 FIFO errors 0 0 MAC control frames 0 0 MAC pause frames 0 0 Oversized frames 0 Jabber frames 0 Fragment frames 0 VLAN tagged frames 0 Code violations 0 Total errors 0 0 Filter statistics: Input packet count 0 Input packet rejects 0 Input DA rejects 0 Input SA rejects 0 Output packet count 0 Output packet pad count 0 Output packet error count 0 CAM destination filters: 0, CAM source filters: 0 Autonegotiation information: Negotiation status: Incomplete Packet Forwarding Engine configuration: Destination slot: 0 (0x00) CoS information: Direction : Output CoS transmit queue Bandwidth Buffer Priority Limit % bps % usec 0 best-effort 95 950000000 95 0 low none 3 network-control 5 50000000 5 0 low none Interface transmit statistics: Disabled
意义
的命令输出部分列出了接口上接收和传输的 Traffic statistics 字节数和数据包数。
显示由指定监管器监管的数据包数
目的
验证监管器评估的数据包数。不支持高级监管器计数器。
行动
show policer
使用操作模式命令并选择性地指定监管器policer-agg-prem
的名称。命令输出显示指定监管器在每个方向上评估的数据包数。
user@host> show policer policer-agg-prem Policers: Name Bytes Packets policer-agg-prem-ge-1/2/0.0-inet-i 10372300 103723
后 -inet-i 缀表示应用于 IPv4 输入流量的监管器。在此示例中,监管器仅适用于输入流量。
意义
命令输出显示指定监管器在每个方向上评估的数据包数。