PTX 路由器上基于类的选择性过滤
PTX 路由器上基于类的选择性过滤
对于受支持的 PTX 系列路由器和线卡,您可以根据源或目标分类(源类使用情况,SCU)和(目标类使用情况,DCU)过滤 IPv4 和 IPv6 流量。这很有用,因为这意味着您可以有选择地对类中的数据包子集(而不是类中的所有数据包)应用过滤器。此外,优化了通过数据包转发引擎 (PFE) 的数据包流,过滤效率更高。
对于服务提供商,基于类的筛选允许您提供高级服务,例如:
-
通过根据源或目标数据包类和其他过滤条件调整数据包的转发类来进行逐跳行为操作。
-
流向某些客户接口的流量速率受限,需要丢弃大量流量(例如,在 DDoS 攻击下)。通常,您需要部署传出接口过滤器来对流量进行速率限制。但是,这可能效率低下,因为在分布式系统中,流量仍然会穿过交换矩阵,并且占用有限的交换矩阵带宽。效率低下在虚拟输出队列系统(如 PTX)中变得更加明显,在执行输出过滤器之前就进入出口队列,输出过滤器中的任何后续丢弃操作都需要补偿 – 需要允许更多流量进入队列,这需要更多的交换矩阵带宽和更多的片上出口缓冲区空间(这是有限的资源)。在将数据包接纳到出口队列之前,在入口管道中执行基于类的过滤器。如果您希望将大量流量丢弃到某些目标,则建议使用此机制而不是常规输出接口过滤器。
基于类的过滤对于通过模仿正常流量模式以应用程序和服务器资源为目标的“低速和慢速”DoS 攻击也很有效。
为了支持基于类的过滤,在 PTX 路由器的转发表引入了两个新的绑定点:source-class
和 destination-class
。
CLI 层次结构如下所示,其中 src-class-name 或 dest-class-name 是您在相应策略中定义的过滤器的名称。
routing-options forwarding-table source-class src-class-name family [inet | inet6] filter <filter-name>
routing-options forwarding-table destination-class dest-class-name family [inet | inet6] filter <filter-name>
您还可以跨多个 SCU 和 DCU 类配置特定于实例的过滤器。默认情况下,仅为过滤器实例化一组计数器和监管器。在特定于实例的过滤器中,将为每个过滤器连接点创建一组单独的计数器和监管器。
firewall family [inet | inet6] filter <filter name> instance-specific
了解 PTX 路由器上基于类的过滤
最初,引入了源类用法 (SCU) 功能,以提供每个源前缀(由源类标识)发送到特定接口的流量的统计信息细分。引入目标类使用情况 (DCU) 最初是为了提供每个目标前缀(由目标类标识)在接口上接收的流量的统计信息细分。
在源或目标查找过程中,源类或目标类都分配给数据包。因此,只有在查找后执行筛选器时,才能评估源和目标筛选器匹配条件。
瞻博网络路由器支持多个过滤器绑定点,下面列出了可能利用源和目标分类结果的绑定点以及使用准则:
-
输出接口滤波器(设置接口<接口名称>系列 inet 滤波器 <output>. 在任何 PTX 平台上都受支持,但如果预期会在稳定状态下丢弃大量流量(例如,在实施 DDoS 攻击缓解筛选器时),则不建议这样做。由于结构带宽和片上出口缓冲区空间有限,丢弃的 DDoS 攻击流量可能无法通过不符合 DDoS 攻击标准的其他流量进行补偿。
-
转发表过滤器查找后的过滤器(设置转发选项家族 inet 过滤器<过滤器名称>输出)。在 Express 2 (PE) 和 Express 3 (ZX) 平台上受支持。但是,过滤器在出口管道中实例化,因此丢弃行为类似于常规输出接口过滤器。
-
源或目标类特定的绑定点(设置路由选项转发表源类 src-class-name 系列 [inet | inet6] 过滤器<过滤器名称>)。在 Express 2 (PE)、Express 3 (ZX) 和 Express 4 (BT) 平台上受支持。此筛选器在入口管道中实例化。这是丢弃大量流量的推荐选项。如果需要覆盖转发类并随后输出队列分配,也建议使用此选项。在虚拟输出队列系统中,队列是在入口管道中选择的,任何覆盖也必须在入口管道中进行。
-
请注意,绑定到源或目标类特定绑定点的筛选器不支持以下筛选器操作:
-
路由实例
-
下一个 IP
-
下一个界面
-
去封装
-
封装
-
-
不能对绑定主机的数据包应用基于类的选择性过滤器。
-
uRPF 查找失败但由 uRPF 故障过滤器恢复的数据包不受 SCU/DCU 查找的限制。因此,不能对此类数据包应用基于类的选择性过滤器。
-
过滤器仅适用于启用了 SCU/DCU 功能的接口上入口的数据包。这意味着无论是否在输出接口上配置 SCU,都将应用过滤器。
-
需要应用基于选择性类的过滤器的数据包可能会导致性能下降。性能下降与传入流量速率、平均数据包大小和受过滤器影响的流量有关。但是,未应用基于选择性类的过滤器的数据包不会影响性能。
-
DCU 计费适用于过滤器丢弃的数据包。
-
SCU 输出计费不适用于过滤器丢弃的数据包。
-
基于类的选择性滤波器不能与接口特定的旋钮一起使用,因为此旋钮仅适用于接口连接的滤波器。
-
不支持基于类的选择性筛选器的列表(输入/输出列表)。
-
不支持逻辑系统。
-
只有 IPv4 和 IPv6 是受支持的有效负载协议。不支持 MPLS。
-
如果数据包同时匹配 SCU 和 DCU 基于类的选择性过滤器,则只会将最后一个过滤器(即 DCU 过滤器)应用于数据包,而不是同时应用于两个过滤器。
示例:基于选择性类的过滤(PTX 路由器)
此示例说明如何根据源或目标分类将防火墙操作(丢弃、拒绝或监管)应用于 IPv4 和 IPv6 流量。它适用于运行 Junos Evolved OS 21.2 版的 PTX10001-36MR、PTX10003-160C、PTX10003-80C、PTX10004 和 PTX10008 路由器,运行 JUNOS Evolved OS 21.4 版的PTX10016路由器,或者运行 Junos OS 21.2 或更高版本软件的 PTX3000、PTX-5000、PTX1000、PTX10002、PTX10008 PTX10016 路由器。
要求
此示例使用 BGP 是因为 BGP 可用于在由客户边缘、提供商边缘和提供商路由器组成的网络拓扑中的设备之间交换路由。请参阅 BGP 配置概述 以了解更多信息。
概述
此示例使用三个路由设备:客户边缘 (CE) 设备、提供商边缘 (PE) 设备和提供商核心 (P) 设备。将显示 IPv4 流量的配置,其中包括两组 SCU 和 DCU 类,以及防火墙过滤器。在下图中,/32 IP 前缀分别表示连接到客户边缘 (CE) 和提供商 (P) 路由器的主机。

在此示例中,我们定义了两类流量:SCU-1 和 SCU-2,第一个分配给子网 172.16.2.0/24 中的前缀,第二个分配给子网 172.16.3.0/24 中的前缀。其他前缀没有任何类作业。如以下 CLI 代码段所示,在 PE 路由器上定义路由策略,以将前缀分配给源类 scu-1 和源类 scu-2。
show policy-options policy-statement scu-class { term gold { from { route-filter 172.16.2.0/24 orlonger; } then source-class scu-1; accept; term silver { from { route-filter 172.16.3.0/24 orlonger; } then source-class scu-2; accept; }
为了考虑从 CE 进入 PE 接口的流量,PE 路由器上定义的名为 dcu-class 的策略使用路由过滤器将流量放入 dcu-1,其他前缀没有类分配。
show policy-options policy-statement dcu-class { term gold { from { route-filter 172.16.5.0/24 orlonger; } then destination-class dcu-1; accept; }
然后将这些策略应用于转发表。
forwarding-table { export [ dcu_class scu_class ]; }
在下一步中,我们将在 PE 路由器上配置过滤器。
show firewall { family inet { filter f1 { term t1 { from { protocol icmp; } then { count c1; } } } } }
并将该过滤器附加到 PE 路由器上的特定源和目标类绑定点。
show routing-options forwarding-table source-class scu-1 { family inet { filter { f1; } } } destination-class dcu-1 { family inet { filter { f1; } } }
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到 CLI 中。
该示例使用静态路由提供用于测试操作的连接和环路接口地址。
设备 CE
set interfaces et-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set interfaces lo0 unit 0 family inet address 172.16.0.1/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext export send-static set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set routing-options static route 10.1.0.0/30 next-hop 10.0.0.2 set routing-options autonomous-system 100
设备 PE
set interfaces et-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces et-1/2/1 unit 0 family inet accounting source-class-usage input set interfaces et-1/2/1 unit 0 family inet accounting destination-class-usage set interfaces et-1/2/1 unit 0 family inet address 10.1.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols bgp group ext neighbor 10.1.0.2 peer-as 300 set policy-options policy-statement dcu_class term gold from route-filter 172.16.5.0/24 orlonger set policy-options policy-statement dcu_class term gold then destination-class dcu-1 set policy-options policy-statement scu_class term gold from route-filter 172.16.2.0/24 orlonger set policy-options policy-statement scu_class term gold then source-class scu-1 set policy-options policy-statement scu_class term silver from route-filter 172.16.3.0/24 orlonger set policy-options policy-statement scu_class term silver then source-class scu-1 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set firewall family inet filter f1 term 0 from protocol icmp set firewall family inet filter f1 term 0 then count c1 set firewall family inet filter f1 term 0 then accept set routing-options autonomous-system 200 set routing-options forwarding-table export dcu_class set routing-options forwarding-table export scu_class
设备 P
set interfaces et-1/2/1 unit 0 family inet address 10.1.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set interfaces lo0 unit 0 family inet address 172.16.0.3/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext export send-static set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.1.0.1 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set routing-options static route 10.0.0.0/30 next-hop 10.1.0.1 set routing-options static route 172.16.2.0/24 discard set routing-options static route 172.16.3.0/24 discard set routing-options static route 172.16.4.0/24 discard set routing-options static route 172.16.5.0/24 discard set routing-options static route 172.16.6.0/24 discard set routing-options static route 172.16.7.0/24 discard set routing-options autonomous-system 300
分步过程
要将源前缀和目标前缀分组到转发类中:
-
在 PE 路由器上创建路由器接口。
[edit interfaces] set et-1/2/0 unit 0 family inet accounting source-class-usage output set et-1/2/0 unit 0 family inet address 10.0.0.2/30 set et-1/2/1 unit 0 family inet accounting source-class-usage input set et-1/2/1 unit 0 family inet accounting destination-class-usage set et-1/2/1 unit 0 family inet address 10.1.0.1/30 set lo0 unit 0 family inet address 192.168.0.2/32
-
在 PE 路由器上配置 BGP。
[edit] set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols bgp group ext neighbor 10.1.0.2 peer-as 300
-
配置 PE 路由器的自治系统 (AS) 编号。
[edit] set routing-options autonomous-system 200
-
在 PE 路由器上配置 DCU 策略。
[edit] set policy-options policy-statement dcu_class term class-1 from route-filter 172.16.5.0/24 orlonger set policy-options policy-statement dcu_class term class-1 then destination-class dcu-1
-
在 PE 路由器上配置 SCU 策略。
[edit] set policy-options policy-statement scu_class term class-1 from route-filter 172.16.2.0/24 orlonger set policy-options policy-statement scu_class term class-1 then source-class scu-1
-
将策略应用到 PE 路由器上的转发表。
[edit] set routing-options forwarding-table export dcu_class set routing-options forwarding-table export scu_class
-
在 PE 路由器上创建过滤器。
[edit] set firewall family inet filter f1 from protocol icmp then count c1
-
将过滤器绑定到 PE 路由器上的源类和目标类绑定点。
将筛选器绑定到目标类用法。
[edit] set routing-options forwarding-table destination-class dcu-1 family inet filter f1
将筛选器绑定到源类用法。
[edit] set routing-options forwarding-table source-class scu-1 family inet filter f1
-
(可选)配置在 PE 路由器上通告直接路由的路由策略。
[edit] set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept
结果
在配置模式下,通过在 PE 路由器上发出 show interfaces
、 show protocols
、 show policy-options
和 show routing-options
命令来确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
show interfaces et-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } et-1/2/1 { unit 0 { family inet { accounting { source-class-usage { input; } } address 10.1.0.1/30; } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
show interface statistics et-1/2/0 Physical interface: et-1/2/0:0, Enabled, Physical link is Up Interface index: 1087, SNMP ifIndex: 622 Link-level type: Ethernet, MTU: 1514, LAN-PHY mode, Speed: 10Gbps, BPDU Error: None, Loop Detect PDU Error: None, MAC-REWRITE Error: None, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Media type: Fiber Device flags : Present Running Interface flags: SNMP-Traps CoS queues : 8 supported, 8 maximum usable queues Current address: e4:5d:37:4e:e8:40, Hardware address: e4:5d:37:4e:e8:40 Last flapped : 2021-03-16 09:33:43 PDT (03:39:51 ago) Statistics last cleared: 2021-03-16 13:13:01 PDT (00:00:33 ago) Input rate : 0 bps (0 pps) Output rate : 0 bps (0 pps) Input errors: 0, Output errors: 0 Active alarms : None Active defects : None PCS statistics Seconds Bit errors 0 Errored blocks 0 PRBS Mode : Disabled Interface transmit statistics: Disabled Link Degrade : Link Monitoring : Disable Logical interface et-1/2/0:0.0 (Index 1047) (SNMP ifIndex 673) Flags: Up SNMP-Traps Encapsulation: ENET2 Input packets : 14 Output packets: 6 Protocol inet, MTU: 1500 Flags: Sendbcast-pkt-to-re, SCU-out Packets Bytes Source class (packet-per-second) (bits-per-second) scu-1 6 504 ( 0)( 0) Addresses, Flags: Is-Preferred Is-Primary Destination: 44.4.4/24, Local: 44.4.4.4, Broadcast: 44.4.4.255 Protocol inet6, MTU: 1500 Flags: None, SCU-out Packets Bytes Source class (packet-per-second) (bits-per-second) scu-1 0 0 ( 0) ( 0) Addresses, Flags: Is-Preferred Is-Primary Destination: 4001::/64, Local: 4001::4001 Addresses, Flags: Is-Preferred Destination: fe80::/64, Local: fe80::e65d:37ff:fe4e:e840 Protocol multiservice, MTU: Unlimited Flags: None
show firewall Filter: f1 Counters: Name Bytes Packets c1 0 0 Filter: v4_instance_new-scu-scu-1 Counters: Name Bytes Packets c_v4_instance_new-scu-scu-1 504 6 Filter: v6_instance_new-scu-scu-1 Counters: Name Bytes Packets c_v6_instance_new-scu-scu-1 0 0
show policy-options policy-statement dcu_class { term class-1 { from { route-filter 172.16.5.0/24 orlonger; } then destination-class dcu-1; } } policy-statement scu_class { term class-1 { from { route-filter 172.16.2.0/24 orlonger; } then source-class scu-1; } } policy-statement send-direct { term 1 { from protocol direct; then accept; } }
show routing-options autonomous-system 200; forwarding-table { export [ dcu_class scu_class ]; }
如果完成设备配置,请从配置模式输入提交。