配置数据包转发行为
了解间接下一跳
Junos OS 支持间接连接下一跃点(也称为第三方下一跃点)的所有路由协议的间接下一跃点概念。
由于内部 BGP (IBGP) 等路由协议可以发送有关间接连接路由的路由信息,因此 Junos OS 依靠 AS 内路由协议(OSPF、IS-IS、RIP 和静态)中的路由来解析最佳直连下一跃点。路由引擎会执行路由解析以确定最佳直接连接的下一跃点,并将路由安装到数据包转发引擎。
默认情况下,Junos OS 不会维护数据包转发引擎转发表中的间接下一跃点到转发下一跃点绑定的路由。因此,当发生重新路由事件时,可能必须更新数千条到转发下一跃点绑定的路由,这会增加路由融合时间。 图 1 展示了禁用了间接下一跃点绑定的转发下一跃点的路由。
![Route to Forwarding Next-Hop Bindings](/documentation/us/en/software/junos/static-routing/images/g016735.gif)
您可以让 Junos OS 在数据包转发引擎转发表中维护与转发下一跃点的间接下一跃点绑定。因此,需要更新的转发下一跃点绑定路由减少了,从而缩短了路由融合时间。 图 2 展示了启用间接下一跃点的转发下一跃点绑定的路由。
![Route to Forwarding Indirect Next-Hop Bindings](/documentation/us/en/software/junos/static-routing/images/g016736.gif)
示例:通过在数据包转发引擎上启用间接下一跃点来优化路由重新融合
此示例说明如何使用间接下一跃点来加速网络融合(例如,在 BGP 网络中),减少发生网络拓扑更改时所需的转发表更改次数。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
在此示例中,通过不相等的路径连接了多台设备。从设备 R1 到设备 R2,通过设备 R3 的路径具有高于通过设备 R4 的路径的 IGP 指标。设备 R1 与设备 R2 有内部 BGP 连接。设备 R0 将多个路由注入网络,设备 R1 将这些路由播发至设备 R2。由于设备 R2 未直接连接到设备 R1,因此设备 R2 的转发表包含间接的下一跃点。内部网关协议(在本例中为 OSPF)在设备 R1、R2、R3 和 R4 之间的内部链路上运行。每台路由器都在宣传其环路接口 IPv4 地址。
在设备 R2 上,该 indirect-next-hop
语句使 Junos OS 能够维护数据包转发引擎转发表中的间接下一跃点与转发下一跃点的绑定。因此,需要更新的转发下一跃点绑定路由减少了,这样在路径发生故障时,路由融合时间就会缩短。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,然后将命令复制并粘贴到层级的 [edit]
CLI 中。
设备 R0
set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.1/30 set interfaces lo0 unit 1 family inet address 10.1.0.1/32 set interfaces lo0 unit 1 family inet address 10.1.0.2/32 set interfaces lo0 unit 1 family inet address 10.1.0.3/32 set interfaces lo0 unit 1 family inet address 10.1.0.4/32 set interfaces lo0 unit 1 family inet address 10.1.0.5/32 set interfaces lo0 unit 1 family inet address 10.1.0.6/32 set interfaces lo0 unit 1 family inet address 10.1.0.7/32 set interfaces lo0 unit 1 family inet address 10.1.0.8/32 set interfaces lo0 unit 1 family inet address 10.1.0.9/32 set routing-options static route 0.0.0.0/0 next-hop 10.0.0.2
设备 R1
set interfaces fe-1/2/0 unit 2 family inet address 10.0.0.2/30 set interfaces fe-1/2/1 unit 5 family inet address 10.0.0.5/30 set interfaces fe-1/2/2 unit 9 family inet address 10.0.0.9/30 set interfaces lo0 unit 2 family inet address 10.1.1.1/32 set protocols bgp export send-local set protocols bgp export send-static set protocols bgp group int type internal set protocols bgp group int local-address 10.1.1.1 set protocols bgp group int neighbor 10.2.2.2 set protocols ospf area 0.0.0.0 interface fe-1/2/1.5 set protocols ospf area 0.0.0.0 interface fe-1/2/2.9 set protocols ospf area 0.0.0.0 interface lo0.2 set policy-options policy-statement send-local from protocol local set policy-options policy-statement send-local from protocol direct set policy-options policy-statement send-local then accept set policy-options policy-statement send-static from protocol static set policy-options policy-statement send-static then accept set routing-options static route 10.1.0.2/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.1/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.3/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.4/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.5/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.6/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.7/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.8/32 next-hop 10.0.0.1 set routing-options static route 10.1.0.9/32 next-hop 10.0.0.1 set routing-options autonomous-system 65500
设备 R2
set interfaces fe-1/2/0 unit 14 family inet address 10.0.0.14/30 set interfaces fe-1/2/1 unit 18 family inet address 10.0.0.18/30 set interfaces fe-1/2/2 unit 21 family inet set interfaces lo0 unit 3 family inet address 10.2.2.2/32 set protocols bgp export send-local set protocols bgp group int type internal set protocols bgp group int local-address 10.2.2.2 set protocols bgp group int family inet unicast set protocols bgp group int family inet-vpn unicast set protocols bgp group int neighbor 10.1.1.1 set protocols ospf area 0.0.0.0 interface fe-1/2/0.14 set protocols ospf area 0.0.0.0 interface fe-1/2/1.18 set protocols ospf area 0.0.0.0 interface lo0.3 set policy-options policy-statement send-local from protocol local set policy-options policy-statement send-local from protocol direct set policy-options policy-statement send-local then accept set routing-options autonomous-system 65500 set routing-options forwarding-table indirect-next-hop
设备 R3
set interfaces fe-1/2/0 unit 6 family inet address 10.0.0.6/30 set interfaces fe-1/2/1 unit 13 family inet address 10.0.0.13/30 set interfaces lo0 unit 4 family inet address 10.3.3.3/32 set protocols ospf area 0.0.0.0 interface fe-1/2/0.6 metric 5000 set protocols ospf area 0.0.0.0 interface fe-1/2/1.13 metric 5000 set protocols ospf area 0.0.0.0 interface lo0.4
设备 R4
set interfaces fe-1/2/0 unit 10 family inet address 10.0.0.10/30 set interfaces fe-1/2/1 unit 17 family inet address 10.0.0.17/30 set interfaces lo0 unit 5 family inet address 10.4.4.4/32 set protocols ospf area 0.0.0.0 interface fe-1/2/0.10 set protocols ospf area 0.0.0.0 interface fe-1/2/1.17 set protocols ospf area 0.0.0.0 interface lo0.5
设备 R5
set interfaces fe-1/2/0 unit 22 family inet address 10.0.0.22/30 set interfaces lo0 unit 6 family inet address 10.5.5.5/32
配置设备 R0
逐步过程
以下示例要求您在配置层次结构中的各个级别上导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 R0:
-
配置接口,包括可注入网络以用于演示的多个路由。
[edit interfaces] user@R0# set fe-1/2/0 unit 1 family inet address 10.0.0.1/30 user@R0# set lo0 unit 1 family inet address 10.1.0.1/32 user@R0# set lo0 unit 1 family inet address 10.1.0.2/32 user@R0# set lo0 unit 1 family inet address 10.1.0.3/32 user@R0# set lo0 unit 1 family inet address 10.1.0.4/32 user@R0# set lo0 unit 1 family inet address 10.1.0.5/32 user@R0# set lo0 unit 1 family inet address 10.1.0.6/32 user@R0# set lo0 unit 1 family inet address 10.1.0.7/32 user@R0# set lo0 unit 1 family inet address 10.1.0.8/32 user@R0# set lo0 unit 1 family inet address 10.1.0.9/32
-
配置静态默认路由以实现网络可访问性。
[edit routing-options] user@R0# set static route 0.0.0.0/0 next-hop 10.0.0.2
-
完成设备配置后,提交配置。
[edit] user@R0# commit
配置设备 R1
逐步过程
以下示例要求您在配置层次结构中的各个级别上导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 R1:
-
配置接口,包括可注入网络以用于演示的多个路由。
[edit interfaces] user@R1# set fe-1/2/0 unit 2 family inet address 10.0.0.2/30 user@R1# set fe-1/2/1 unit 5 family inet address 10.0.0.5/30 user@R1# set fe-1/2/2 unit 9 family inet address 10.0.0.9/30 user@R1# set lo0 unit 2 family inet address 10.1.1.1/32
-
配置 BGP。
[edit protocols] user@R1# set bgp export send-local user@R1# set bgp export send-static user@R1# set bgp group int type internal user@R1# set bgp group int local-address 10.1.1.1 user@R1# set bgp group int neighbor 10.2.2.2
-
配置 OSPF。
[edit protocols] user@R1# set ospf area 0.0.0.0 interface fe-1/2/1.5 user@R1# set ospf area 0.0.0.0 interface fe-1/2/2.9 user@R1# set ospf area 0.0.0.0 interface lo0.2
-
配置路由策略。
[edit] user@R1# set policy-options policy-statement send-local from protocol local user@R1# set policy-options policy-statement send-local from protocol direct user@R1# set policy-options policy-statement send-local then accept user@R1# set policy-options policy-statement send-static from protocol static user@R1# set policy-options policy-statement send-static then accept
-
配置一组静态路由到设备 R0 上配置的接口集。
[edit] user@R1# set routing-options static route 10.1.0.2/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.1/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.3/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.4/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.5/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.6/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.7/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.8/32 next-hop 10.0.0.1 user@R1# set routing-options static route 10.1.0.9/32 next-hop 10.0.0.1
-
配置自治系统 (AS) 标识符。
[edit] user@R1# set routing-options autonomous-system 65500
-
完成设备配置后,提交配置。
[edit] user@R1# commit
配置设备 R2
逐步过程
以下示例要求您在配置层次结构中的各个级别上导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 R2:
-
配置接口,包括可注入网络以用于演示的多个路由。
[edit interfaces] user@R2# set fe-1/2/0 unit 14 family inet address 10.0.0.14/30 user@R2# set fe-1/2/1 unit 18 family inet address 10.0.0.18/30 user@R2# set fe-1/2/2 unit 21 family inet address 10.0.0.21/30; user@R2# set lo0 unit 3 family inet address 10.2.2.2/32
-
配置 BGP。
[edit] user@R2# set protocols bgp export send-local user@R2# set protocols bgp group int type internal user@R2# set protocols bgp group int local-address 10.2.2.2 user@R2# set protocols bgp group int family inet unicast user@R2# set protocols bgp group int family inet-vpn unicast user@R2# set protocols bgp group int neighbor 10.1.1.1
-
配置 OSPF。
[edit] user@R2# set protocols ospf area 0.0.0.0 interface fe-1/2/0.14 user@R2# set protocols ospf area 0.0.0.0 interface fe-1/2/1.18 user@R2# set protocols ospf area 0.0.0.0 interface lo0.3
-
配置路由策略。
[edit] user@R2# set policy-options policy-statement send-local from protocol local user@R2# set policy-options policy-statement send-local from protocol direct user@R2# set policy-options policy-statement send-local then accept
-
配置 AS 标识符。
[edit] user@R2# set routing-options autonomous-system 65500
-
在转发平面中启用间接的下一跃点。
[edit] user@R2# set routing-options forwarding-table indirect-next-hop
-
完成设备配置后,提交配置。
[edit] user@R2# commit
结果
通过发出 show interfaces
、 show protocols
、 show policy-options
和 show routing-options
命令来确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
设备 R0
user@R0# show interfaces fe-1/2/0 { unit 1 { family inet { address 10.0.0.1/30; } } } lo0 { unit 1 { family inet { address 10.1.0.1/32; address 10.1.0.2/32; address 10.1.0.3/32; address 10.1.0.4/32; address 10.1.0.5/32; address 10.1.0.6/32; address 10.1.0.7/32; address 10.1.0.8/32; address 10.1.0.9/32; } } }
user@R0# show routing-options static { route 0.0.0.0/0 next-hop 10.0.0.2; }
设备 R1
user@R1# show interfaces fe-1/2/0 { unit 2 { family inet { address 10.0.0.2/30; } } } fe-1/2/1 { unit 5 { family inet { address 10.0.0.5/30; } } } fe-1/2/2 { unit 9 { family inet { address 10.0.0.9/30; } } } lo0 { unit 2 { family inet { address 10.1.1.1/32; } } }
user@R1# show protocols bgp { export [ send-local send-static ]; group int { type internal; local-address 10.1.1.1; neighbor 10.2.2.2; } } ospf { area 0.0.0.0 { interface fe-1/2/1.5; interface fe-1/2/2.9; interface lo0.2; } }
user@R1# show policy-options policy-statement send-local { from protocol [ local direct ]; then accept; } policy-statement send-static { from protocol static; then accept; }
user@R1# show routing-options static { route 10.1.0.2/32 next-hop 10.0.0.1; route 10.1.0.1/32 next-hop 10.0.0.1; route 10.1.0.3/32 next-hop 10.0.0.1; route 10.1.0.4/32 next-hop 10.0.0.1; route 10.1.0.5/32 next-hop 10.0.0.1; route 10.1.0.6/32 next-hop 10.0.0.1; route 10.1.0.7/32 next-hop 10.0.0.1; route 10.1.0.8/32 next-hop 10.0.0.1; route 10.1.0.9/32 next-hop 10.0.0.1; } autonomous-system 65500;
设备 R2
user@R2# show interfaces fe-1/2/0 { unit 14 { family inet { address 10.0.0.14/30; } } } fe-1/2/1 { unit 18 { family inet { address 10.0.0.18/30; } } } fe-1/2/2 { unit 21 { family inet { address 10.0.0.21/30 } } } lo0 { unit 3 { family inet { address 10.2.2.2/32; } } }
user@R2# show protocols bgp { export send-local; group int { type internal; local-address 10.2.2.2; family inet { unicast; } family inet-vpn { unicast; } neighbor 10.1.1.1; } } ospf { area 0.0.0.0 { interface fe-1/2/0.14; interface fe-1/2/1.18; interface lo0.3; } }
user@R2# show policy-options policy-statement send-local { from protocol [ local direct ]; then accept; }
user@R2# show routing-options autonomous-system 65500; forwarding-table { indirect-next-hop; }
配置设备 R3、设备 R4 和设备 R5,如 CLI 快速配置中所示。
验证
确认配置工作正常。
验证路由是否具有预期的间接下一跃点标志
目的
请确保设备 R2 配置为在数据包转发引擎转发表中保持间接下一跃点与转发下一跃点的绑定。
行动
user@R2> show krt indirect-next-hop show krt indirect-next-hop Indirect Nexthop: Index: 1048575 Protocol next-hop address: 10.255.3.1 RIB Table: __mpls-oam__.mpls.0 Label: Swap 299968 Policy Version: 0 References: 1 Locks: 2 0x95bc514 Flags: 0x3 INH Session ID: 0xa INH Version ID: 1 Ref RIB Table: unknown Next hop: 10.50.244.9 via ge-2/0/2.0 Label operation: Swap 299968, Push 299792(top) Label TTL action: no-prop-ttl, no-prop-ttl(top) Session Id: 0x9 IGP FRR Interesting proto count : 0
意义
0x3
输出中的标志表示设备 R2 配置为保持数据包转发引擎转发表中的间接下一跃点与转发下一跃点绑定。当语句indirect-next-hop
从配置中删除或停用时,此标志将变为0x2
。采用 Trio 模块化端口集中器 (MPC) 芯片组的 Junos MX 系列路由器默认支持间接下一跳,不能禁用。因此,即使indirect-next-hop
未在下forwarding-options
配置该功能,默认情况下也有效。因此,0x3
标志不适用于 Trio 模块化端口集中器 (MPC)。
命令 show krt indirect-next-hop
是隐藏的,因此是无文档的。命令 show krt indirect-next-hop
在此处显示,因为这是唯一一个验证间接下一跃点功能的命令。当然,最好的验证方法是在路径故障后在重新融合期间监控网络性能。