BFD 多跳模式
BFD 多跳模式
重要
该功能在 7.2.0 GA 及以后版本支持。
功能介绍
默认配置下,不论是被 OSPF、BGP 还是静态路由引用,FortiGate 的 BFD 邻居只支持直连网段的设备。如果 FortiGate 的 BGP 邻居不是直连网络的设备,需要在 BFD 下配置 multihop-template,指定 BFD 流量的源(自身 IP)和目的(邻居 IP),这里配置的 BFD 邻居可以是多跳的不同网段的设备 IP。
- 当 BFD 被静态路由引用时,src 和 dst 需要配置 Host 级别的 netmask,IPv4 为 32 位,IPv6 为 128 位。
- 当 BFD 被动态路由(如 OSPF 和 BGP)引用时,src 和 dst 可以配置为网段(包含 BFD 本地地址和邻居地址),如 192.168.13.0/24,2100::/64,邻居地址通过动态路由协议获取。这样可以方便的配置多个 BFD 多跳邻居。
- 不支持 OSPF 和静态路由的 BFD 多跳模式(OSPF 邻居本来就必须直连建立)。
同时可以在 multihop-template 中配置 BFD 的相关参数与认证功能,这些 BFD 参数(匹配模板的 BFD 流量)优先于接口及全局级别。
在只有 BFD 多跳邻居的情况下,配置 multihop-template 后,不需要再配置 BFD neighbor。
config router {bfd | bfd6} config multihop-template edit <ID> set src <IP address/netmask> set dst <IP address/netmask> set bfd-desired-min-tx <integer> set bfd-required-min-rx <integer> set bfd-detect-mult <integer> set auth-mode {none | md5} set md5-key <password> next end end
网络拓扑

- FW1 与 FW2 建立 IPv4 与 IPv6 的 EBGP 邻居,网段非直连。
- FW1 与 FW2 之间的 IPv4/IPv6 EBGP 邻居启用多跳 BFD。
配置步骤
基础网络配置(略)。
在 FW1 和 FW2 的 port2 上分别开启 BFD,并分别配置 IPv4 和 IPv6 的多跳 BFD 模版(多跳环境下必须配置)。
config system interface edit "port2" set bfd enable next endFW1: config router bfd config multihop-template edit 1 set src 202.103.12.0 255.255.255.0 set dst 202.103.13.0 255.255.255.0 next end end config router bfd6 config multihop-template edit 1 set src 2100::/64 set dst 2200::/64 next end endFW2: config router bfd config multihop-template edit 1 set src 202.103.13.0 255.255.255.0 set dst 202.103.12.0 255.255.255.0 next end end config router bfd6 config multihop-template edit 1 set src 2200::/64 set dst 2100::/64 next end end在 FW1 和 FW2 上分别配置 BGP,配置 EBGP 邻居(包含 IPv4 和 IPv6),宣告 IPv4 和 IPv6 内网网段。
FW1: config router bgp set as 10086 set router-id 202.103.12.2 config neighbor edit "202.103.13.2" set bfd enable set ebgp-enforce-multihop enable set remote-as 10010 next edit "2200::2" set bfd enable set ebgp-enforce-multihop enable set remote-as 10010 next end config network edit 1 set prefix 10.10.1.0 255.255.255.0 next end config network6 edit 1 set prefix6 2300::/64 next end endFW2: config router bgp set as 10010 set router-id 202.103.13.2 config neighbor edit "202.103.12.2" set bfd enable set ebgp-enforce-multihop enable set remote-as 10086 next edit "2100::2" set bfd enable set ebgp-enforce-multihop enable set remote-as 10086 next end config network edit 1 set prefix 10.10.2.0 255.255.255.0 next end config network6 edit 1 set prefix6 2400::/64 next end end
结果验证
在 FW1 上查看 BFD IPv4 和 IPv6 邻居状态均为 UP(FW2 略)。
FW1 # get router info bfd requests BFD Peer Requests: client types(ct in 0x): 01=external 02=static 04=ospf 08=bgp 10=pim-sm src=202.103.12.2 dst=202.103.13.2 ct=08 ifi=4 type=SM FW1 # get router info6 bfd requests BFD Peer Requests: client types(ct in 0x): 01=external 02=static 04=ospf 08=bgp 10=pim-sm src=2100::2 dst=2200::2 ct=08 ifi=4 type=SMFW1 # get router info bfd neighbor OurAddress NeighAddress State Interface LDesc/RDesc 202.103.12.2 202.103.13.2 UP port2 3/4/M OurAddress: 2100::2FW1 # get router info6 bfd neighbor NeighAddress: 2200::2 State: UP Interface: port2 Desc: 4/3 Multi-hop在 FW1 上查看 BFD 相关日志与抓包(FW2 略),IPv4 和 IPv6 的 BFD 状态由 INIT 变为 UP。
date=2023-08-14 time=17:07:51 eventtime=1692004071014368092 tz="+0800" logid="0103020304" type="event" subtype="router" level="warning" vd="root" logdesc="Routing log warning" msg="BFD: BFD session[202.103.12.2->202.103.13.2,49154,port2,3,multi]: state INIT -> UP local_diag=0x00" date=2023-08-14 time=17:07:51 eventtime=1692004070970891127 tz="+0800" logid="0103020304" type="event" subtype="router" level="warning" vd="root" logdesc="Routing log warning" msg="BFD: BFD session[2100::2->2200::2,49155,port2,4,multi]: state INIT -> UP local_diag=0x00"
在 FW1 上查看 IPv4 和 IPv6 的 BGP 邻居与 BGP 路由状态,邻居状态正常建立,IPv4 和 IPv6 的 BGP 路由学习正常。
FW1 # get router info bgp summary VRF 0 BGP router identifier 202.103.12.2, local AS number 10086 BGP table version is 1 3 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/DOWN State/PfxRcd 202.103.13.2 4 10010 35 37 1 0 0 00:27:54 1 2200::2 4 10010 36 36 1 0 0 00:26:57 1 Total number of neighbors 2 FW1 # get router info routing-table bgp Routing table for VRF=0 B 10.10.2.0/24 [20/0] via 202.103.13.2 (recursive via 202.103.12.1, port2), 00:27:31, [1/0] FW1 # get router info6 routing-table bgp Routing table for VRF=0 B 2400::/64 [20/0] via 2200::2 (recursive via 2100::1, port2), 00:27:34, [1024/0]模拟 IPv6 的 BFD 中断,查看 FW1 上 BFD IPv6 邻居 DOWN。
FW1 # get router info6 bfd neighbor OurAddress: 2100::2 NeighAddress: 2200::2 State: DOWN Interface: port2 Desc: 10/12 Multi-hop在 FW1 上查看 BFD 相关日志,BFD DOWN 后,对应的 IPv6 BGP 邻居关系跟随 DOWN。
date=2023-08-14 time=17:33:33 eventtime=1692005613533793725 tz="+0800" logid="0103020300" type="event" subtype="router" level="warning" vd="root" logdesc="BGP neighbor status changed" msg="BGP: %BGP-5-ADJCHANGE: VRF 0 neighbor 2200::2 DOWN User reset" date=2023-08-14 time=17:33:33 eventtime=1692005613533476560 tz="+0800" logid="0103020300" type="event" subtype="router" level="warning" vd="root" logdesc="BGP neighbor status changed" msg="BGP: %BGP-5-ADJCHANGE: VRF 0 neighbor 2200::2 DOWN BGP Notification CEASE" ...... date=2023-08-14 time=17:33:33 eventtime=1692005613533219142 tz="+0800" logid="0103020300" type="event" subtype="router" level="warning" vd="root" logdesc="BGP neighbor status changed" msg="BGP: %BGP-5-ADJCHANGE: VRF 0 neighbor 2200::2 DOWN BFD DOWN; User reset added" date=2023-08-14 time=17:33:33 eventtime=1692005613532847101 tz="+0800" logid="0103020304" type="event" subtype="router" level="warning" vd="root" logdesc="Routing log warning" msg="BFD: BFD session[2100::2->2200::2,49155,port2,4,multi]: state UP -> DOWN local_diag=0x01"在 FW1 上查看 IPv4 和 IPv6 的 BGP 邻居状态,IPv6 邻居断开,并开始重建 EBGP 邻居。
FW1 # get router info bgp summary VRF 0 BGP router identifier 202.103.12.2, local AS number 10086 BGP table version is 2 2 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/DOWN State/PfxRcd 202.103.13.2 4 10010 113 114 1 0 0 01:24:53 1 2200::2 4 10010 111 113 0 0 0 never Active Total number of neighbors 2 FW1 # get router info bgp summary VRF 0 BGP router identifier 202.103.12.2, local AS number 10086 BGP table version is 2 3 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/DOWN State/PfxRcd 202.103.13.2 4 10010 114 115 1 0 0 01:25:49 1 2200::2 4 10010 116 119 2 0 0 00:00:55 1抓包查看 IPv6 BFD DOWN 的报文,FW2 发现检测超时,向 FW1 发送 BFD Time Expired 报文,两端互相发送 AdminDOWN 的 BFD 控制报文,随后双向 BFD 字段中的 Diagnostic Code 为空,状态为 DOWN。

在 FW1 上删除 IPv4 的 BFD 多跳模版,模拟未配置多跳模板情况下的 BFD 多跳状态。
FW1 # config router bfd FW1 (bfd) # config multihop-template FW1 (multihop-template) # delete 1 FW1 (multihop-template) # end FW1 (bfd) # end查看 FW1 和 FW2 上的 IPv4 BFD 邻居状态,均变为 DOWN。
FW1 # get router info bfd neighbor OurAddress NeighAddress State Interface LDesc/RDesc 202.103.12.2 202.103.13.2 DOWN port2 16/0 FW2 # get router info bfd neighbor OurAddress NeighAddress State Interface LDesc/RDesc 202.103.13.2 202.103.12.2 DOWN port2 8/17/MFW1 和 FW2 的 IPv4 BGP 邻居都没有发生重建。
FW1 # get router info bgp summary VRF 0 BGP router identifier 202.103.12.2, local AS number 10086 BGP table version is 2 3 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 202.103.13.2 4 10010 123 124 1 0 0 01:32:59 1 2200::2 4 10010 124 127 2 0 0 00:08:05 1 FW2 # get router info bgp summary VRF 0 BGP router identifier 202.103.13.2, local AS number 10010 BGP table version is 6 3 BGP AS-PATH entries 0 BGP community entries Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 202.103.12.2 4 10086 215 216 5 0 0 01:41:32 1 2100::2 4 10086 193 203 6 0 0 00:16:37 1在 FW1 上查看路由相关日志,显示 IPv4 BFD 为 Admin Down,后续没有 IPv4 BGP 断开的日志。
date=2023-08-14 time=19:40:54 eventtime=1692013254437017862 tz="+0800" logid="0103020304" type="event" subtype="router" level="warning" vd="root" logdesc="Routing log warning" msg="BFD: BFD session[202.103.12.2->202.103.13.2,49168,port2,11,multi]: state UP -> ADMIN DOWN local_diag=0x27"在 FW2 上查看路由相关日志,显示 IPv4 BFD Down,后续没有也 IPv4 BGP 断开的日志。
date=2023-08-14 time=19:40:54 eventtime=1692013254462567015 tz="+0800" logid="0103020304" type="event" subtype="router" level="warning" vd="root" logdesc="Routing log warning" msg="BFD: BFD session[202.103.13.2->202.103.12.2,49159,port2,8,multi]: state UP -> DOWN local_diag=0x23"同时抓包查看 IPv4 的 BFD,FW1 向 FW2 发送了 Administratively Down 类型的 BFD。

随后 FW1 → FW2 方向的 BFD Down 中的 Diagnostic Code 变为空,FW2 → FW1 方向的 BFD Down 中的 Diagnostic Code 变为 Neighbor Signaled Session Down。


注意事项
- Admin 类型的 Down 不会导致 BGP 邻居重建。
- BFD Down 后触发了 BGP 邻居重建,如果 BFD 一直没有 UP,则重建后的 BGP 邻居不会受任何影响,除非再次发生了 BFD 从 UP 到 Down 的状态转换(静态路由不是这样)。