示例:在内部会话和对等BGP上配置 BFD
此示例展示如何使用双向转发检测 (BFD) 协议BGP内部路由 (IBGP) 对等会话以检测网络故障。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
在 IBGP 会话上启用 BFD 的最低配置是,在参与 BFD 会话的所有BGP的配置中包括 bfd-liveness-detection minimum-interval
该语句。语句 minimum-interval
指定用于检测故障的最小传输和接收间隔。具体而言,此值表示本地路由设备在此之后传输 hello 数据包的最小间隔,以及路由设备希望接收其已建立 BFD 会话的邻接方发送回复的最小间隔。您可以配置一个 1 到 255,000 毫秒的值。
或者,您也可使用 和 语句单独指定最小传输和接收 transmit-interval minimum-interval
minimum-receive-interval
间隔。有关这些语句和其他可选 BFD 配置语句的信息,请参阅 bfd-liveness-detection
。
BFD 是一种消耗系统资源的密集协议。为基于 路由引擎 的会话指定 BFD 小于 100 毫秒的最低间隔时间,对于分布式 BFD 会话指定不到 10 毫秒可能会导致 BFD 翻动。
根据您的网络环境,这些额外的建议可能适用:
为防止 BFD 在常规切换路由引擎翻动,请为基于该路由引擎的会话指定最低 5000 毫秒的间隔。此最低值是必需的,因为路由引擎切换事件期间,RPD、MIBD 和 SNMPD 等进程占用 CPU 资源超过指定的阈值。因此,BFD 处理和计划因 CPU 资源缺乏而受到影响。
对于在双机箱群集控制链路情景中保持启用的 BFD 会话,当第一个控制链路出现故障时,请指定 6000 毫秒的最小间隔,以防止 LACP 在基于 路由引擎 的会话的辅助节点上翻动。
对于具有大量 BFD 会话的大型网络部署,请为基于 路由引擎 的会话指定最低 300 毫秒的间隔,为分布式 BFD 会话指定 100 毫秒。
对于具有大量 BFD 会话的大规模网络部署,请与瞻博网络联系以了解更多信息。
对于配置了不间断活动路由 (NSR) 时在 路由引擎 切换事件期间保持开启的 BFD 会话,请为基于 路由引擎 的会话指定最低 2500 毫秒的间隔。对于配置了 NSR 的分布式 BFD 会话,不会更改最小间隔建议,并且仅取决于网络部署。
默认路由实例(主路由器)、路由实例和逻辑系统支持 BFD。此示例显示逻辑系统上 BFD。
图 1 显示了具有内部对等会话的典型网络。

配置
CLI快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以匹配网络配置,然后将命令复制并粘贴到 层次结构级别的 CLI 中 [edit]
。
设备 A
set logical-systems A interfaces lt-1/2/0 unit 1 description to-B set logical-systems A interfaces lt-1/2/0 unit 1 encapsulation ethernet set logical-systems A interfaces lt-1/2/0 unit 1 peer-unit 2 set logical-systems A interfaces lt-1/2/0 unit 1 family inet address 10.10.10.1/30 set logical-systems A interfaces lo0 unit 1 family inet address 192.168.6.5/32 set logical-systems A protocols bgp group internal-peers type internal set logical-systems A protocols bgp group internal-peers traceoptions file bgp-bfd set logical-systems A protocols bgp group internal-peers traceoptions flag bfd detail set logical-systems A protocols bgp group internal-peers local-address 192.168.6.5 set logical-systems A protocols bgp group internal-peers export send-direct set logical-systems A protocols bgp group internal-peers bfd-liveness-detection minimum-interval 1000 set logical-systems A protocols bgp group internal-peers neighbor 192.163.6.4 set logical-systems A protocols bgp group internal-peers neighbor 192.168.40.4 set logical-systems A protocols ospf area 0.0.0.0 interface lo0.1 passive set logical-systems A protocols ospf area 0.0.0.0 interface lt-1/2/0.1 set logical-systems A policy-options policy-statement send-direct term 2 from protocol direct set logical-systems A policy-options policy-statement send-direct term 2 then accept set logical-systems A routing-options router-id 192.168.6.5 set logical-systems A routing-options autonomous-system 17
设备 B
set logical-systems B interfaces lt-1/2/0 unit 2 description to-A set logical-systems B interfaces lt-1/2/0 unit 2 encapsulation ethernet set logical-systems B interfaces lt-1/2/0 unit 2 peer-unit 1 set logical-systems B interfaces lt-1/2/0 unit 2 family inet address 10.10.10.2/30 set logical-systems B interfaces lt-1/2/0 unit 5 description to-C set logical-systems B interfaces lt-1/2/0 unit 5 encapsulation ethernet set logical-systems B interfaces lt-1/2/0 unit 5 peer-unit 6 set logical-systems B interfaces lt-1/2/0 unit 5 family inet address 10.10.10.5/30 set logical-systems B interfaces lo0 unit 2 family inet address 192.163.6.4/32 set logical-systems B protocols bgp group internal-peers type internal set logical-systems B protocols bgp group internal-peers local-address 192.163.6.4 set logical-systems B protocols bgp group internal-peers export send-direct set logical-systems B protocols bgp group internal-peers bfd-liveness-detection minimum-interval 1000 set logical-systems B protocols bgp group internal-peers neighbor 192.168.40.4 set logical-systems B protocols bgp group internal-peers neighbor 192.168.6.5 set logical-systems B protocols ospf area 0.0.0.0 interface lo0.2 passive set logical-systems B protocols ospf area 0.0.0.0 interface lt-1/2/0.2 set logical-systems B protocols ospf area 0.0.0.0 interface lt-1/2/0.5 set logical-systems B policy-options policy-statement send-direct term 2 from protocol direct set logical-systems B policy-options policy-statement send-direct term 2 then accept set logical-systems B routing-options router-id 192.163.6.4 set logical-systems B routing-options autonomous-system 17
设备 C
set logical-systems C interfaces lt-1/2/0 unit 6 description to-B set logical-systems C interfaces lt-1/2/0 unit 6 encapsulation ethernet set logical-systems C interfaces lt-1/2/0 unit 6 peer-unit 5 set logical-systems C interfaces lt-1/2/0 unit 6 family inet address 10.10.10.6/30 set logical-systems C interfaces lo0 unit 3 family inet address 192.168.40.4/32 set logical-systems C protocols bgp group internal-peers type internal set logical-systems C protocols bgp group internal-peers local-address 192.168.40.4 set logical-systems C protocols bgp group internal-peers export send-direct set logical-systems C protocols bgp group internal-peers bfd-liveness-detection minimum-interval 1000 set logical-systems C protocols bgp group internal-peers neighbor 192.163.6.4 set logical-systems C protocols bgp group internal-peers neighbor 192.168.6.5 set logical-systems C protocols ospf area 0.0.0.0 interface lo0.3 passive set logical-systems C protocols ospf area 0.0.0.0 interface lt-1/2/0.6 set logical-systems C policy-options policy-statement send-direct term 2 from protocol direct set logical-systems C policy-options policy-statement send-direct term 2 then accept set logical-systems C routing-options router-id 192.168.40.4 set logical-systems C routing-options autonomous-system 17
配置设备 A
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航指南CLI,请参阅 CLI 用户 指南 中的 在配置模式下CLI 编辑器。
要配置设备 A:
将 CLI设置为逻辑系统 A。
user@host> set cli logical-system A
配置接口。
[edit interfaces lt-1/2/0 unit 1] user@host:A# set description to-B user@host:A# set encapsulation ethernet user@host:A# set peer-unit 2 user@host:A# set family inet address 10.10.10.1/30 [edit interfaces lo0 unit 1] user@host:A# set family inet address 192.168.6.5/32
配置BGP。
包括设备 B 和设备 C 的语句,即使设备
neighbor
A 未直接连接到设备 C。[edit protocols bgp group internal-peers] user@host:A# set type internal user@host:A# set local-address 192.168.6.5 user@host:A# set export send-direct user@host:A# set neighbor 192.163.6.4 user@host:A# set neighbor 192.168.40.4
配置 BFD。
[edit protocols bgp group internal-peers] user@host:A# set bfd-liveness-detection minimum-interval 1000
您必须在连接对等方上配置相同的最小间隔。
(可选)配置 BFD 追踪。
[edit protocols bgp group internal-peers] user@host:A# set traceoptions file bgp-bfd user@host:A# set traceoptions flag bfd detail
配置OSPF。
[edit protocols ospf area 0.0.0.0] user@host:A# set interface lo0.1 passive user@host:A# set interface lt-1/2/0.1
配置接受直接路由的策略。
此情景的其他有用选项可能是接受通过路由或本地路由OSPF路由。
[edit policy-options policy-statement send-direct term 2] user@host:A# set from protocol direct user@host:A# set then accept
配置路由器 ID 和自治系统 (AS) 编号。
[edit routing-options] user@host:A# set router-id 192.168.6.5 user@host:A# set autonomous-system 17
如果完成设备配置,请从配置
commit
模式输入 。 重复这些步骤以配置设备 B 和设备 C。
结果
在配置模式下,输入 、 和 show interfaces
命令 show policy-options
以确认 show protocols
您的 show routing-options
配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
user@host:A# show interfaces lt-1/2/0 { unit 1 { description to-B; encapsulation ethernet; peer-unit 2; family inet { address 10.10.10.1/30; } } } lo0 { unit 1 { family inet { address 192.168.6.5/32; } } }
user@host:A# show policy-options policy-statement send-direct { term 2 { from protocol direct; then accept; } }
user@host:A# show protocols bgp { group internal-peers { type internal; traceoptions { file bgp-bfd; flag bfd detail; } local-address 192.168.6.5; export send-direct; bfd-liveness-detection { minimum-interval 1000; } neighbor 192.163.6.4; neighbor 192.168.40.4; } } ospf { area 0.0.0.0 { interface lo0.1 { passive; } interface lt-1/2/0.1; } }
user@host:A# show routing-options router-id 192.168.6.5; autonomous-system 17;
验证
确认配置工作正常。
验证是否启用了 BFD
目的
验证 IBGP 对等方之间是否启用了 BFD。
行动
在操作模式下,输入 show bgp neighbor
命令。您可以使用过滤器 | match bfd
缩小输出范围。
user@host:A> show bgp neighbor | match bfd Options: <BfdEnabled> BFD: enabled, up Trace file: /var/log/A/bgp-bfd size 131072 files 10 Options: <BfdEnabled> BFD: enabled, up Trace file: /var/log/A/bgp-bfd size 131072 files 10
意义
输出显示逻辑系统 A 有两个启用了 BFD 的邻设备。未启用 BFD 时,输出显示 BFD: disabled, down
, <BfdEnabled>
且缺少选项。如果 BFD 启用且会话关闭,则输出显示 BFD: enabled, down
。输出还显示,BFD 相关事件正在写入日志文件,因为已配置追踪操作。
验证 BFD 会话是否启动
目的
验证 BFD 会话是否已启动,并查看有关 BFD 会话的详细信息。
行动
在操作模式下,输入 show bfd session extensive
命令。
user@host:A> show bfd session extensive Detect Transmit Address State Interface Time Interval Multiplier 192.163.6.4 Up 3.000 1.000 3 Client BGP, TX interval 1.000, RX interval 1.000 Session up time 00:54:40 Local diagnostic None, remote diagnostic None Remote state Up, version 1 Logical system 12, routing table index 25 Min async interval 1.000, min slow interval 1.000 Adaptive async TX interval 1.000, RX interval 1.000 Local min TX interval 1.000, minimum RX interval 1.000, multiplier 3 Remote min TX interval 1.000, min RX interval 1.000, multiplier 3 Local discriminator 10, remote discriminator 9 Echo mode disabled/inactive Multi-hop route table 25, local-address 192.168.6.5 Detect Transmit Address State Interface Time Interval Multiplier 192.168.40.4 Up 3.000 1.000 3 Client BGP, TX interval 1.000, RX interval 1.000 Session up time 00:48:03 Local diagnostic None, remote diagnostic None Remote state Up, version 1 Logical system 12, routing table index 25 Min async interval 1.000, min slow interval 1.000 Adaptive async TX interval 1.000, RX interval 1.000 Local min TX interval 1.000, minimum RX interval 1.000, multiplier 3 Remote min TX interval 1.000, min RX interval 1.000, multiplier 3 Local discriminator 14, remote discriminator 13 Echo mode disabled/inactive Multi-hop route table 25, local-address 192.168.6.5 2 sessions, 2 clients Cumulative transmit rate 2.0 pps, cumulative receive rate 2.0 pps
意义
输出 TX interval 1.000, RX interval 1.000
表示使用 语句配置的 minimum-interval
设置。所有其他输出都表示 BFD 的默认设置。要修改默认设置,请添加 语句下的可选 bfd-liveness-detection
语句。
查看详细的 BFD 事件
目的
查看 BFD 追踪文件的内容,帮助进行故障排除(如有必要)。
行动
在操作模式下,输入 file show /var/log/A/bgp-bfd
命令。
user@host:A> file show /var/log/A/bgp-bfd Aug 15 17:07:25 trace_on: Tracing to "/var/log/A/bgp-bfd" started Aug 15 17:07:26.492190 bgp_peer_init: BGP peer 192.163.6.4 (Internal AS 17) local address 192.168.6.5 not found. Leaving peer idled Aug 15 17:07:26.493176 bgp_peer_init: BGP peer 192.168.40.4 (Internal AS 17) local address 192.168.6.5 not found. Leaving peer idled Aug 15 17:07:32.597979 task_connect: task BGP_17.192.163.6.4+179 addr 192.163.6.4+179: No route to host Aug 15 17:07:32.599623 bgp_connect_start: connect 192.163.6.4 (Internal AS 17): No route to host Aug 15 17:07:36.869394 task_connect: task BGP_17.192.168.40.4+179 addr 192.168.40.4+179: No route to host Aug 15 17:07:36.870624 bgp_connect_start: connect 192.168.40.4 (Internal AS 17): No route to host Aug 15 17:08:04.599220 task_connect: task BGP_17.192.163.6.4+179 addr 192.163.6.4+179: No route to host Aug 15 17:08:04.601135 bgp_connect_start: connect 192.163.6.4 (Internal AS 17): No route to host Aug 15 17:08:08.869717 task_connect: task BGP_17.192.168.40.4+179 addr 192.168.40.4+179: No route to host Aug 15 17:08:08.869934 bgp_connect_start: connect 192.168.40.4 (Internal AS 17): No route to host Aug 15 17:08:36.603544 advertising receiving-speaker only capabilty to neighbor 192.163.6.4 (Internal AS 17) Aug 15 17:08:36.606726 bgp_read_message: 192.163.6.4 (Internal AS 17): 0 bytes buffered Aug 15 17:08:36.609119 Initiated BFD session to peer 192.163.6.4 (Internal AS 17): address=192.163.6.4 ifindex=0 ifname=(none) txivl=1000 rxivl=1000 mult=3 ver=255 Aug 15 17:08:36.734033 advertising receiving-speaker only capabilty to neighbor 192.168.40.4 (Internal AS 17) Aug 15 17:08:36.738436 Initiated BFD session to peer 192.168.40.4 (Internal AS 17): address=192.168.40.4 ifindex=0 ifname=(none) txivl=1000 rxivl=1000 mult=3 ver=255 Aug 15 17:08:40.537552 BFD session to peer 192.163.6.4 (Internal AS 17) up Aug 15 17:08:40.694410 BFD session to peer 192.168.40.4 (Internal AS 17) up
意义
建立路由之前, No route to host
消息会显示在输出中。建立路由后,最后两行显示两个 BFD 会话都启动。
在停用和重新激活环回接口之后查看详细的 BFD 事件
目的
查看在关闭路由器或交换机之后,然后恢复运行后将会怎样。要模拟停用路由器或交换机,请停用逻辑系统 B 上的环路接口。
行动
在配置模式下,输入
deactivate logical-systems B interfaces lo0 unit 2 family inet
命令。user@host:A# deactivate logical-systems B interfaces lo0 unit 2 family inet user@host:A# commit
在操作模式下,输入
file show /var/log/A/bgp-bfd
命令。user@host:A> file show /var/log/A/bgp-bfd ... Aug 15 17:20:55.995648 bgp_read_v4_message:9747: NOTIFICATION received from 192.163.6.4 (Internal AS 17): code 6 (Cease) subcode 6 (Other Configuration Change) Aug 15 17:20:56.004508 Terminated BFD session to peer 192.163.6.4 (Internal AS 17) Aug 15 17:21:28.007755 task_connect: task BGP_17.192.163.6.4+179 addr 192.163.6.4+179: No route to host Aug 15 17:21:28.008597 bgp_connect_start: connect 192.163.6.4 (Internal AS 17): No route to host
在配置模式下,输入
activate logical-systems B interfaces lo0 unit 2 family inet
命令。user@host:A# activate logical-systems B interfaces lo0 unit 2 family inet user@host:A# commit
在操作模式下,输入
file show /var/log/A/bgp-bfd
命令。user@host:A> file show /var/log/A/bgp-bfd ... Aug 15 17:25:53.623743 advertising receiving-speaker only capabilty to neighbor 192.163.6.4 (Internal AS 17) Aug 15 17:25:53.631314 Initiated BFD session to peer 192.163.6.4 (Internal AS 17): address=192.163.6.4 ifindex=0 ifname=(none) txivl=1000 rxivl=1000 mult=3 ver=255 Aug 15 17:25:57.570932 BFD session to peer 192.163.6.4 (Internal AS 17) up