示例:使用每秒数据包数速率限制过滤器保护路由引擎
此示例说明如何配置基于数据包每秒的速率限制过滤器以提高安全性。它将应用于环路接口,以帮助保护路由引擎免受拒绝服务攻击。
这种类型的过滤器和监管器组合只是多层方法中的一个元素,可用于帮助保护路由引擎。为了完全保护路由引擎,还需要其他保护层。请参阅 第一天:保护 M、MX 和 T 系列 上的路由引擎,了解更多信息。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
配置
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。在配置模式下使用 CLI 编辑器https://www.juniper.net/documentation/en_US/junos/information-products/pathway-pages/junos-cli/junos-cli.html
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI 中。[edit]
set firewall policer police_pps if-exceeding-pps pps-limit 1k set firewall policer police_pps if-exceeding-pps packet-burst 150 set firewall policer police_pps then discard set firewall family inet filter my_pps_filter term term1 then policer police_pps set interfaces lo0 unit 0 family inet filter input my_pps_filter set interfaces lo0 unit 0 family inet address 127.0.0.1/32
配置监管器和无状态防火墙过滤器
分步过程
要配置监管器和 无状态防火墙过滤器 :police_pps
my_pps_filter
配置监管器模板 。
police_pps
[edit firewall] user@host# set policer police_pps if-exceeding-pps pps-limit 1k user@host# set policer police_pps if-exceeding-pps packet-burst 150 user@host# set policer police_pps then discard
创建无状态防火墙过滤器 。
my_pps_filter
[edit] user@host# edit firewall family inet filter my_pps_filter
配置一个过滤器术语,该术语使用监管器 按协议家族对流量限制进行速率限制。
police_pps
[edit firewall family inet filter my_pps_filter] user@host# set term term1 then policer police_pps
将无状态防火墙过滤器应用于环路逻辑接口
分步过程
要将过滤器 应用于环路接口,请执行以下操作:my_pps_filter
配置将应用无状态防火墙过滤器的逻辑环路接口。
[edit] user@host# edit interfaces lo0 unit 0
将无状态防火墙过滤器应用于环路接口。
[edit interfaces lo0 unit 0] user@host# set family inet filter input my_pps_filter
配置环路接口的接口地址。
[edit interfaces lo0 unit 0] user@host# set family inet address 127.0.0.1/32
成果
通过输入 配置模式命令确认无状态防火墙过滤器的配置。show firewall
如果命令输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@host# show firewall family inet{ filter my_pps_filter { term term1 { then policer police_pps; } } } policer police_pps { if-exceeding-pps { pps-limit 1k; packet-burst 150; } then discard; }
通过输入 配置模式命令确认接口的配置。show interfaces lo0
如果命令输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@host# show interfaces lo0 unit 0 { family inet { filter { input my_pps_filter; } address 127.0.0.1/32; } }
如果完成设备配置,请从配置模式输入提交。
user@host# commit
验证
验证过滤器的操作
目的
要确认配置工作正常,请输入 操作模式命令。show firewall filter my_pps_filter
以下输出是从另一台主机运行到受测路由器的快速 ping 的结果。为了在输出中显示结果,在ping测试期间使用了设置和设置。pps-limit
50packet-burst
10
操作
user@host> show firewall filter my_pps_filter Filter: my_pps_filter Policers: Name Bytes Packets police_pps-term1 8704 17