配置 RPD 基础架构中路由前缀的优先级
前缀优先级可帮助用户确定某些路由或前缀的优先级,以实现更好的融合,并提供差异化的服务。在具有大量路由的网络中,由于网络拓扑的变化,控制路由的更新顺序有时非常重要。在系统级别,Junos OS 基于启发式方法实现合理的默认值,以确定路由的更新顺序。但是,默认行为并不总是最佳的。前缀优先级使用户能够控制路由从 LDP 或 OSPF 更新到 rpd 以及从 rpd 更新到内核的顺序。Junos OS 策略语言得到扩展,允许用户通过协议中的现有导入策略为前缀设置相对优先级(高和低)。根据标记的优先级,路由被放置在不同的优先级队列中。如果拓扑发生更改,将首先在路由表中更新高优先级前缀,然后更新低优先级前缀。在同一优先级内,路由将继续按字典顺序更新。未显式分配优先级的路由被视为中等优先级。
在开始在 rpd 中为 OSPF、LDP 和 BGP 等协议配置前缀优先级之前:
配置路由器接口。
配置 MPLS。
配置 OSPF、BGP 和 LDP 协议。
要配置 OSPF 协议的优先级 high
,请执行以下操作:
LDP 继承自 OSPF。
要配置 LDP 的优先级 high
:
配置从 OSPF 导入的策略术语。
[edit policy-options policy-statement policy-name] user@host# set term term-name
例如:
[edit policy-options policy-statement ospf-import] user@host# set term ospf_ldp
配置术语以接受来自 OSPF 的路由和优先级。
[edit policy-options policy-statement ospf_import term ospf_ldp] user@host# set from protocol ospf user@host# set from route-filter destination-prefix match-type
例如:
[edit policy-options policy-statement ospf_import term ospf_ldp] user@host# set from protocol ospf user@host# set from route-filter 172.16.25.3/32 exact
验证配置。
[edit] user@host# show policy-options policy-statement ospf-import { term ospf_ldp { from { protocol ospf ; route-filter 172.16.25.3/32 exact; } then { priority high; accept; } } }
要配置 BGP 协议的优先级 high
,请执行以下操作:
配置策略术语。
[edit policy-options policy-statement policy-name] user@host# set term term-name
例如:
[edit policy-options policy-statement prio-for-bgp] user@host# set term bgp_prio
将所需路由指定为匹配条件。
[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set from protocol bgp user@host# set from route-filter destination-prefix match-type
例如:
[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set from protocol bgp user@host# set from route-filter 172.16.50.1/32 exact
指定要接受的路由,如果与前面的条件匹配,则设置路由的优先级
high
。[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set then priority high user@host# set then accept
验证配置。
policy-statement prio_for_bgp { term bgp_prio { from { protocol bgp; route-filter 172.16.50.1/32 exact; } then { priority high; accept; } } }
对于 BGP,对于 L3VPN,您还可以根据路由识别符 (RD) 值配置优先级。例如,您可以使用路由识别符 51.51.51.51.51:111 配置 BGP 的优先级。
要根据路由识别符 (RD) 值配置 BGP 的优先级,请执行以下操作:
配置策略术语。
[edit policy-options policy-statement policy-name] user@host# set term term-name
例如:
[edit policy-options policy-statement prio-for-bgp] user@host# set term bgp_prio
将所需路由指定为匹配条件。
[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set from rib bgp.l3vpn.0 user@host# set from route-filter destination-prefix match-type user@host# set from route-distinguisher route-distinguisher value
例如:
[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set from rib bgp.l3vpn.0 user@host# set from route-filter 172.16.1.1/32 exact user@host# set from route-distinguisher RD1
指定要接受的路由,如果与前面的条件匹配,则设置路由的优先级
high
。[edit policy-options policy-statement prio-for-bgp term bgp_prio] user@host# set then priority high user@host# set then accept
验证配置。
policy-statement prio_for_bgp { term bgp_prio { from { protocol rib bgp.l3vpn.0; route-filter 172.16.1.1/32 exact; route-distinguisher RD1; } then { priority high; accept; } } }
低优先级前缀仅安装在路由表中的高优先级前缀之后。您还可以为要设置为低优先级的路由配置优先级 low
,其优先级与优先级 high
类似。
仅当路由从 RIB 推送到 FIB 时,才会应用优先级。因此,您无法修改已安装的路由的优先级。更改已安装路由的优先级没有意义。如果尝试更改已安装路由的优先级,则会显示输出差异:
user@R1> show route 172.16.25.3 extensive | match state
State: <FlashAll>
State: <Active Int HighPriority> <=== OSPF
Validation State: unverified
State: <FlashAll>
State: <Active Int> <=== LDP
Validation State: unverified
由于路由已安装在 FIB 中,因此 LDP 不会将优先级显示为高。
重新启动路由守护程序以移除路由并再次添加路由,从 OSPF 和 LDP 协议的角度来看,这反映了正确的优先级。
user@R1>restart routing
Routing protocols process signalled but still running, waiting 8 seconds more Routing protocols process started, pid 4512 user@R1>show route 172.16.25.3 extensive |match state
State: <FlashAll> State: <Active Int HighPriority> <=== OSPF Validation State: unverified State: <FlashAll> State: <Active Int HighPriority> <=== LDP Validation State: unverified