示例:配置分层监管器以限制静态环境中的服务速率
此示例说明如何配置分层监管器,并将监管器应用于 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 快速配置
要快速配置此示例,请将以下配置命令复制到文本文件中,删除所有换行符,然后将命令粘贴到层次结构级别的 [edit] CLI 中。
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 variable-interface-name unit]包含[edit dynamic-profiles profile-name interfaces逻辑接口变量名称(例如 $junos-underlying-interface-unit $junos-interface-unit或 )。
创建新的动态配置文件。
[edit] user@host# set dynamic-profiles basic-profile
interface-name使用路由器用于匹配接收接口的接口名称的内部$junos-interface-ifd-name变量定义 variable 语句。[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
将逻辑接口配置为单元 0 及其 IPv4 (inet) 协议家族接口。
[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 优先级字段 internet-control (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
注意:高级监管器的带宽限制不得大于聚合监管器的带宽限制。对于高级监管器,对于不合格流量流中的数据包,唯一可配置的作是丢弃该数据包。
结果
输入 configuration 命令,确认 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 层入口流量进行分层速率限制,请从物理接口配置引用监管器。
结果
输入 configuration 命令,确认 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;
}
}
}
验证
确认配置工作正常。
显示接口的流量统计信息
目的
验证通过物理接口的流量。
行动
对物理接口 ge-1/2/0 使用 show interfaces 作模式命令,并包括 detail or 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 输入流量的监管器。在此示例中,监管器仅应用于输入流量。
意义
命令输出显示指定监管器在每个方向上评估的数据包数。