BGP 多路径
BGP 多路径
网络需求
当存在多条 ECMP(Equal-Cost Multipath)的 BGP 路由到达目标网络时,默认情况下只有第 1 个路由(先学习到的)会被放入路由表。
当开启 BGP multipath 功能后,所有这些 ECMP 的 BGP 路由都会被放入路由表,实现出站流量的负载均衡。允许同时使用多条等效路径,以提高网络性能和容错性。
网络拓扑

- FortiGate 与 Router1 和 Router2 分别建立 iBGP 邻居,FortiGate 宣告自己的内网网段。
- Router1 和 Router2 分别与 Router3 建立 eBGP 邻居,Router3 宣告自己的内网网段。
配置步骤
基础网络配置(略)。
配置 FortiGate 的 BGP,与 Router1 和 Router2 分别建立 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 edit "10.10.1.5" set soft-reconfiguration enable set remote-as 65001 next end config network edit 1 set prefix 10.10.3.0 255.255.255.0 next end end配置 Router1 的 BGP,与 FortiGate 建立 iBGP 邻居,将路由下一跳修改为自己。与 Router3 建立 eBGP 邻居。
config router bgp set as 65001 set router-id 10.10.1.1 config neighbor edit "10.10.1.2" set next-hop-self enable set soft-reconfiguration enable set remote-as 65001 next edit "10.10.2.1" set soft-reconfiguration enable set remote-as 65002 next end end配置 Router2 的 BGP,与 FortiGate 建立 iBGP 邻居,将路由下一跳修改为自己。与 Router3 建立 eBGP 邻居。
config router bgp set as 65001 set router-id 10.10.1.5 config neighbor edit "10.10.1.6" set next-hop-self enable set soft-reconfiguration enable set remote-as 65001 next edit "10.10.2.1" set soft-reconfiguration enable set remote-as 65002 next end end配置 Router3 的 BGP,分别与 Router1 和 Router2 建立 eBGP 邻居。
config router bgp set as 65002 set router-id 10.10.2.1 config neighbor edit "10.10.2.2" set soft-reconfiguration enable set remote-as 65001 next edit "10.10.2.3" set soft-reconfiguration enable set remote-as 65001 next end config network edit 1 set prefix 10.10.4.0 255.255.255.0 next end end
结果验证
在 FortiGate 上查看 BGP 学习到的路由,可以看到分别从 iBGP 邻居 Router1 和 Router2 学习到了 Router3 发布的 BGP 路由,下一跳分别为 Router1 和 Router2。
FortiGate # get router info bgp network VRF 0 BGP table version is 4, 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 *> 10.10.3.0/24 0.0.0.0 100 32768 0 i <-/1> *>i10.10.4.0/24 10.10.1.1 0 100 0 0 65002 i <-/1> * i 10.10.1.5 0 100 0 0 65002 i <-/-> Total number of prefixes 2 FortiGate # get router info bgp network 10.10.4.0 VRF 0 BGP routing table entry for 10.10.4.0/24 Paths: (2 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer Original VRF 0 65002 10.10.1.1 from 10.10.1.1 (10.10.1.1) Origin IGP metric 0, localpref 100, valid, internal, best Last update: Thu Jan 18 11:46:37 2024 Original VRF 0 65002 10.10.1.5 from 10.10.1.5 (10.10.1.5) Origin IGP metric 0, localpref 100, valid, internal Last update: Thu Jan 18 11:47:05 2024但在 FortiGate 上只有下一跳为 Router1 的 BGP 路由被放入路由表。
FortiGate # get router info routing-table bgp Routing table for VRF=0 B 10.10.4.0/24 [200/0] via 10.10.1.1 (recursive is directly connected, port2), 02:41:00, [1/0]配置 FortiGate 的 BGP 开启 ibgp-multipath。
config router bgp set ibgp-multipath enable end再次查看 FortiGate 的路由表,下一跳为 Router2 的 BGP 路由也被放入路由表,路由下一跳在 Router1 和 Router2 间负载。
FortiGate # get router info routing-table bgp Routing table for VRF=0 B 10.10.4.0/24 [200/0] via 10.10.1.1 (recursive is directly connected, port2), 00:00:55, [1/0] [200/0] via 10.10.1.5 (recursive is directly connected, port3), 00:00:55, [1/0]在 Router3 上查看 BGP 学习到的路由,可以看到分别从 eBGP 邻居 Router1 和 Router2 学习到了 FortiGate 发布的 BGP 路由,下一跳分别为 Router1 和 Router2(eBGP 路由会自动更改下一跳为自身)。
Router3 # get router info bgp network VRF 0 BGP table version is 2, local router ID is 10.10.2.1 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 *> 10.10.3.0/24 10.10.2.2 0 0 0 65001 i <-/1> * 10.10.2.3 0 0 0 65001 i <-/-> *> 10.10.4.0/24 0.0.0.0 100 32768 0 i <-/1> Total number of prefixes 2但在 Router3 上只有下一跳为 Router1 的 BGP 路由被放入路由表。
Router3 # get router info bgp network VRF 0 BGP table version is 2, local router ID is 10.10.2.1 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 *> 10.10.3.0/24 10.10.2.2 0 0 0 65001 i <-/1> * 10.10.2.3 0 0 0 65001 i <-/-> *> 10.10.4.0/24 0.0.0.0 100 32768 0 i <-/1> Total number of prefixes 2 Router3 # get router info bgp network 10.10.3.0 VRF 0 BGP routing table entry for 10.10.3.0/24 Paths: (2 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 10.10.2.3 Original VRF 0 65001 10.10.2.2 from 10.10.2.2 (10.10.1.1) Origin IGP metric 0, localpref 100, valid, external, best Last update: Thu Jan 18 14:17:19 2024 Original VRF 0 65001 10.10.2.3 from 10.10.2.3 (10.10.1.5) Origin IGP metric 0, localpref 100, valid, external Last update: Thu Jan 18 14:17:13 2024配置 FortiGate 的 BGP 开启 ebgp-multipath。
config router bgp set ebgp-multipath enable end再次查看 Router3 的路由表,下一跳为 Router2 的 BGP 路由也被放入路由表,路由下一跳在 Router1 和 Router2 间负载。
Router3 # get router info routing-table bgp Routing table for VRF=0 B 10.10.3.0/24 [20/0] via 10.10.2.2 (recursive is directly connected, port2), 00:00:21, [1/0] [20/0] via 10.10.2.3 (recursive is directly connected, port2), 00:00:21, [1/0]