BGP 下一跳递归
2025/10/29大约 2 分钟
BGP 下一跳递归
网络需求
默认情况下,当 BGP 路由的下一跳需要递归解析时,不会被考虑通过其他 BGP 路由进行递归。启 recursive-next-hop 后,才通过其他 BGP 路由进行递归。
网络拓扑

- FortiGate 想要学习 Router2 的网段 10.10.2.0/24。
- FortiGate 从 Router1 学习到了 Router2 的网段 10.10.2.0/24,下一跳为 10.10.1.5。
- FortiGate 从 Router1 学习到了 10.10.1.4/30 的路由,下一跳为 10.10.1.1。
配置步骤
配置基础网络(略)。
配置 FortiGate 的 BGP,与 Router1 建立 iBGP 邻居。
config router bgp set as 65001 set router-id 10.10.1.2 config neighbor edit "10.10.1.1" set soft-reconfiguration enable set remote-as 65001 next end end配置 Router1 的 BGP,与 FortiGate 建立 iBGP 邻居,与 Router2 建立 eBGP 邻居,发布网段 10.10.1.4/30。
config router bgp set as 65001 set router-id 10.10.1.1 config neighbor edit "10.10.1.2" set soft-reconfiguration enable set remote-as 65001 next edit "10.10.1.5" set soft-reconfiguration enable set remote-as 65002 next end config network edit 1 set prefix 10.10.1.4 255.255.255.252 next end end配置 Router2 的 BGP,与 Router1 建立 eBGP 邻居,发布网段 10.10.2.0/24。
config router bgp set as 65002 set router-id 10.10.1.5 config neighbor edit "10.10.1.6" set soft-reconfiguration enable set remote-as 65001 next end config network edit 1 set prefix 10.10.2.0 255.255.255.0 next end end
结果验证
FortiGate 从 Router1 学习到了两条 BGP 路由:
- Router2 发布的路由,下一跳为 Router2 的接口 IP。
- Router1 发布的路由,下一跳为 Router1 的接口 IP。
FortiGate # get router info bgp network VRF 0 BGP table version is 1, local router ID is 10.10.1.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight RouteTag Path *>i10.10.1.4/30 10.10.1.1 0 100 0 0 i <-/1> *>i10.10.2.0/24 10.10.1.5 0 100 0 0 65002 i <-/1> Total number of prefixes 2但是 Router2 发布的路由未被 FortiGate 放入路由表,因为默认配置下,其下一跳 10.10.1.5 是无法通过 BGP 路由递归的。
FortiGate # get router info routing-table bgp Routing table for VRF=0 B 10.10.1.4/30 [200/0] via 10.10.1.1 (recursive is directly connected, port2), 00:06:20, [1/0]在 FortiGate 上开启 BGP 的 recursive-next-hop。
config router bgp set recursive-next-hop enable end再次查看 FortiGate 的路由表中的 BGP 路由,Router2 发布的路由被放入路由表,下一跳通过 Router1 发布的 BGP 路由递归。
FortiGate # get router info routing-table bgp Routing table for VRF=0 B 10.10.1.4/30 [200/0] via 10.10.1.1 (recursive is directly connected, port2), 00:08:35, [1/0] B 10.10.2.0/24 [200/0] via 10.10.1.5 (recursive via 10.10.1.1, port2), 00:00:02, [1/0]