示例:全球为路由过滤器配置 Walkup,以提高运营效率
如果您担心策略性能,请使用 Walkup 功能,因为跨多个策略术语拆分路由过滤器。Walkup 功能支持在一个策略术语下整合路由过滤器。
此示例说明如何为带路由过滤器的策略语句全局配置路由过滤器步行功能。在全球级别配置时,路由过滤器步行选项适用于所有策略语句。此示例将策略术语的默认行为与多个路由过滤器一起在全球范围内更改,以便必须在本地建立对默认“无步行”行为的任何恢复。
要求
此示例使用以下硬件和软件组件:
瞻博网络路由器
13.3 或更高版本的 Junos 操作系统
在本地配置路由过滤器步行之前,请确保您已:
正确配置的路由策略或路由策略集
需要将多个路由过滤器术语整合到更少的路由策略术语中
概述
路由协议与其他运行相同路由协议的路由器交换信息。在许多情况下,路由过滤器用于路由策略语句,以过滤用于导入或导出的前缀。在某些情况下,当路由过滤器被拆分为许多单独的术语时,性能会受到影响。路由过滤器步行功能允许整合策略语句条款以提高运营效率。
此示例使用 BGP,但相同的步行功能适用于支持输入或输出路由过滤的任何路由协议。
您可以配置 Juniper Networks 路由器,以便使用路由过滤器在策略语句中更改术语的默认操作。默认情况下,一个术语中的所有路由过滤器只进行一次最长的匹配尝试。Walkup 功能允许路由器在从最长匹配到更不具体的术语中“向上走”路由过滤器,以搜索真实情况。这允许在策略语句中整合多个术语并提高相应的运营效率。
此示例会针对所有策略语句改变全球默认行为。您仍然可以为单个策略配置 no-walkup
。
拓扑
在 中的示例网络中 图 1,路由器 CE1 是另一家供应商的路由器。其余的是瞻博网络路由器。除路由器 CE1 外,可在图中的任何路由器上配置 Walkup 功能。路由器 CE1 的供应商可能或不可能支持类似功能。

在示例中,使用以下地址:
10.0.0.0/16
10.0.0.0/8
10.0.0.0/8
虽然地址空间并非专门保留用于文档,但由于此地址空间提供的灵活性和现实场景,因此本主题中使用了专用 RFC 1918 10.0.0.0/8
地址空间。
全局配置路由过滤器步行
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除任何换行符,更改地址和接口等详细信息以匹配您的网络配置,然后将命令复制粘贴到层次结构级别的 [edit]
CLI 中。
设备 PE1
set policy-options defaults route-filter walkup set policy-options policy-statement routeset1-import term prefixes1 from route-filter 10.0.0.0/16 prefix-length-range /22-/24 set policy-options policy-statement routeset1-import term prefixes1 from route-filter 10.0.0.0/8 orlonger set policy-options policy-statement routeset1-import term prefixes1 then accept set policy-options policy-statement routeset1-import term reject-the-rest then reject set policy-options policy-statement import-route-filter-a term import-routes from protocol bgp set policy-options policy-statement import-route-filter-a term import-routes from policy routeset1-import set policy-options policy-statement import-route-filter-a term import-routes then next policy set policy-options policy-statement import-route-filter-a term all-others then reject set policy-options policy-statement route-filter-a-export term all then reject set protocols bgp group routeset1 type external set protocols bgp group routeset1 neighbor 10.0.10.13 import import-route-filter-a set protocols bgp group routeset1 neighbor 10.0.10.13 family inet unicast set protocols bgp group routeset1 neighbor 10.0.10.13 export route-filter-a-export set protocols bgp group routeset1 neighbor 10.0.10.13 peer-as 64506
程序
逐步过程
以下示例要求您导航到配置层次结构中的各个级别。有关导航 CLI 的信息,请参阅 Junos OS CLI 用户指南中的在配置模式下使用 CLI 编辑器
要配置路由器 PE1 以执行全局步行,并在一个术语中组合多个路由过滤器:
全局配置 Walkup 功能。
[edit policy-options defaults] user@PE1# set route-filter walkup
为名为
routeset1-import
的导入策略配置策略语句。[edit policy-options] user@PE1# set policy-statement routeset1-import term prefixes1 from route-filter 10.0.0.0/16 prefix-length-range /22-/24 user@PE1# set policy-statement routeset1-import term prefixes1 from route-filter 10.0.0.0/8 orlonger user@PE1# set policy-statement routeset1-import term prefixes1 then accept user@PE1# set policy-statement routeset1-import term reject-the-rest then reject
配置导出策略语句的策略选项。
[edit policy-options] user@PE1# set policy-statement import-route-filter-a term import-routes from protocol bgp user@PE1# set policy-statement import-route-filter-a term import-routes from policy routeset1-import user@PE1# set policy-statement import-route-filter-a term import-routes then next policy user@PE1# set policy-statement route-filter-a-export term all-others then reject
将导入和导出策略应用到 BGP 邻接方。
[edit protocols bgp] user@PE1# set group routeset1 type external user@PE1# set group routeset1 neighbor 10.0.10.13 import import-route-filter-a user@PE1# set group routeset1 neighbor 10.0.10.13 family inet unicast user@PE1# set group routeset1 neighbor 10.0.10.13 export route-filter-a-export user@PE1# set group routeset1 neighbor 10.0.10.13 peer-as 64506
结果
在配置模式下,输入 show protocols
和 show policy-options
命令以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@PE1# show policy-options defaults { route-filter walkup; } policy-statement routeset1-import { term prefixes1 { from { route-filter 10.0.0.0/16 prefix-length-range /22-/24; route-filter 10.0.0.0/8 orlonger; } then accept; } term reject-the-rest { then reject; } } policy-statement import-route-filter-a { term import-routes { from { protocol bgp; policy routeset1-import; } then next policy; } term all-others { then reject; } } policy-statement route-filter-a-export { term all { then reject; } }
user@PE!# show protocols bgp group routeset1 { type external; neighbor 10.0.10.13 { import import-route-filter-a; family inet { unicast; } export router-filter-a-export; peer-as 64506; } }
如果完成设备配置,请在配置模式下输入 commit
。
验证
验证路由过滤器操作
目的
显示有关路由的预期信息,以确认路由过滤器是否正常工作。
请注意, 10.0.0.0/8 orlonger
过滤器的范围包括 10.0.0.0/16 prefix-length-range /22-/24
过滤器。也就是说,前缀为 8 位或以上的路 10.0.0.0
由也可能是前缀在 22 到 24 位之间的路由。如果未启用 Walkup 功能,则会拒绝路由,成为 10.0.0.0/16
隐藏路由。如果 Walkup 功能按预期运行,则策略会接受这样的 10.0.0.0/16
路由。
行动
在操作模式下,输入 show route protocolbgp 10.0.0.0/16
命令。确保这不是 10.0.0.0/16
隐藏的路由。
user@PE1>show route protocol bgp 10.0.0.0/16 inet.0: 520762 destinations, 520764 routes (520760 active, 0 holddown, 2 hidden) + = Active Route, - = Last Active, * = Both 10.0.0.0/16 *[BGP/170] 01:07:37, localpref 100 AS path: 64506, I, validation-state: unverified > to 10.0.100.13 via xe-0/2/0.0
作为进一步检查,确保不应接受的路由为隐藏路由。在操作模式下,输入 show route protocol bgp ip-address-prefix hidden
命令验证此。
意义
在配置的策略路由过滤器术语中不是最长匹配的路由的存在表明,该步行功能正在全局运行。