示例:为静态路由配置 BFD 以加快网络故障检测速度
此示例展示如何为静态路由配置双向转发检测 (BFD)。
要求
此示例不需要除设备初始化之外的特殊配置。
概述
静态路由的实践应用程序有很多。静态路由通常在网络边缘用于支持存根网络的附件,考虑到网络的单点和出口,它非常适合静态路由的简单性。另外Junos OS,静态路由的全局优先级为 5。如果可以到达指定的下一跳跃,静态路由将被激活。
此示例使用下一跃点地址 172.16.1.2 配置从提供商网络到客户网络的静态路由 192.168.47.0/24。您也可使用 172.16.1.1 的下一跃点地址配置从客户网络到提供商网络的静态默认路由 0.0.0.0/0。
为了演示,在设备 B 和设备 D 上配置了一些环路接口。这些环路接口提供对 ping 的地址,从而验证静态路由是否工作。
图 1 显示了示例网络。
拓扑
配置
CLI快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以匹配网络配置,然后将命令复制并粘贴到 层次结构级别的 CLI 中 [edit]
。
设备 B
set interfaces ge-1/2/0 unit 0 description B->D set interfaces ge-1/2/0 unit 0 family inet address 172.16.1.1/24 set interfaces lo0 unit 57 family inet address 10.0.0.1/32 set interfaces lo0 unit 57 family inet address 10.0.0.2/32 set routing-options static route 192.168.47.0/24 next-hop 172.16.1.2 set routing-options static route 192.168.47.0/24 bfd-liveness-detection minimum-interval 1000 set routing-options static route 192.168.47.0/24 bfd-liveness-detection description Site-xxx set protocols bfd traceoptions file bfd-trace set protocols bfd traceoptions flag all
设备 D
set interfaces ge-1/2/0 unit 1 description D->B set interfaces ge-1/2/0 unit 1 family inet address 172.16.1.2/24 set interfaces lo0 unit 2 family inet address 192.168.47.5/32 set interfaces lo0 unit 2 family inet address 192.168.47.6/32 set routing-options static route 0.0.0.0/0 next-hop 172.16.1.1 set routing-options static route 0.0.0.0/0 bfd-liveness-detection minimum-interval 1000 set protocols bfd traceoptions file bfd-trace set protocols bfd traceoptions flag all
程序
逐步过程
以下示例要求您在配置层次结构中导航各个级别。有关导航指南CLI,请参阅 Junos OS CLI 指南 中的 在配置模式下使用 CLI编辑器。
要针对静态路由配置 BFD:
在设备 B 上配置接口。
[edit interfaces] user@B# set ge-1/2/0 unit 0 description B->D user@B# set ge-1/2/0 unit 0 family inet address 172.16.1.1/24 user@B# set lo0 unit 57 family inet address 10.0.0.1/32 user@B# set lo0 unit 57 family inet address 10.0.0.2/32
在设备 B 上,创建静态路由并设置下一跃点地址。
[edit routing-options] user@B# set static route 192.168.47.0/24 next-hop 172.16.1.2
在设备 B 上,为静态路由配置 BFD。
[edit routing-options] user@B# set static route 192.168.47.0/24 bfd-liveness-detection minimum-interval 1000 set routing-options static route 192.168.47.0/24 bfd-liveness-detection description Site-xxx
在设备 B 上,配置 BFD 的追踪操作。
[edit protocols] user@B# set bfd traceoptions file bfd-trace user@B# set bfd traceoptions flag all
如果完成设备 B 配置,请提交配置。
[edit] user@B# commit
在设备 D 上,配置接口。
[edit interfaces] user@D# set ge-1/2/0 unit 1 description D->B user@D# set ge-1/2/0 unit 1 family inet address 172.16.1.2/24 user@D# set lo0 unit 2 family inet address 192.168.47.5/32 user@D# set lo0 unit 2 family inet address 192.168.47.6/32
在设备 D 上,创建静态路由并设置下一跃点地址。
[edit routing-options] user@D# set static route 0.0.0.0/0 next-hop 172.16.1.1
在设备 D 上,为静态路由配置 BFD。
[edit routing-options] user@D# set static route 0.0.0.0/0 bfd-liveness-detection minimum-interval 1000
在设备 D 上,配置 BFD 的跟踪操作。
[edit protocols] user@D# set bfd traceoptions file bfd-trace user@D# set bfd traceoptions flag all
如果完成设备 D 配置,请提交配置。
[edit] user@D# commit
结果
通过发出 、 和 show interfaces
show protocols
命令确认 show routing-options
您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
设备 B
user@B# show interfaces ge-1/2/0 { unit 0 { description B->D; family inet { address 172.16.1.1/24; } } } lo0 { unit 57 { family inet { address 10.0.0.1/32; address 10.0.0.2/32; } } }
user@D# show protocols bfd { traceoptions { file bfd-trace; flag all; } }
user@B# show routing-options static { route 192.168.47.0/24 { next-hop 172.16.1.2; bfd-liveness-detection { description Site- xxx; minimum-interval 1000; } } }
设备 D
user@D# show interfaces ge-1/2/0 { unit 1 { description D->B; family inet { address 172.16.1.2/24; } } } lo0 { unit 2 { family inet { address 192.168.47.5/32; address 192.168.47.6/32; } } }
user@D# show routing-options static { route 0.0.0.0/0 { next-hop 172.16.1.1; bfd-liveness-detection { description Site - xxx; minimum-interval 1000; } } }
验证
确认配置工作正常。
验证 BFD 会话是否启动
目的
验证 BFD 会话是否已启动,并查看有关 BFD 会话的详细信息。
行动
在操作模式下,输入 show bfd session extensive
命令。
user@B> show bfd session extensive Detect Transmit Address State Interface Time Interval Multiplier 172.16.1.2 Up lt-1/2/0.0 3.000 1.000 3 Client Static, description Site-xxx, TX interval 1.000, RX interval 1.000 Session up time 00:14:30 Local diagnostic None, remote diagnostic None Remote state Up, version 1 Replicated, routing table index 172 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 2, remote discriminator 1 Echo mode disabled/inactive 1 sessions, 1 clients Cumulative transmit rate 1.0 pps, cumulative receive rate 1.0 pps
仅在 description Site- <xxx> SRX 系列设备上受支持。
如果每个客户端都有多个说明字段,则显示"等等"以及第一个说明字段。
user@D> show bfd session extensive Detect Transmit Address State Interface Time Interval Multiplier 172.16.1.1 Up lt-1/2/0.1 3.000 1.000 3 Client Static, TX interval 1.000, RX interval 1.000 Session up time 00:14:35 Local diagnostic None, remote diagnostic None Remote state Up, version 1 Replicated, routing table index 170 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 1, remote discriminator 2 Echo mode disabled/inactive 1 sessions, 1 clients Cumulative transmit rate 1.0 pps, cumulative receive rate 1.0 pps
意义
输出 TX interval 1.000, RX interval 1.000
表示使用 语句配置的 minimum-interval
设置。所有其他输出表示 BFD 的默认设置。要修改默认设置,请添加 语句下的可选 bfd-liveness-detection
语句。
查看详细的 BFD 事件
目的
查看 BFD 追踪文件的内容,帮助进行故障排除(如有必要)。
行动
在操作模式下,输入 file show /var/log/bfd-trace
命令。
user@B> file show /var/log/bfd-trace Nov 23 14:26:55 Data (9) len 35: (hex) 42 46 44 20 70 65 72 69 6f 64 69 63 20 78 6d 69 74 20 72 Nov 23 14:26:55 PPM Trace: BFD periodic xmit rt tbl index 172 Nov 23 14:26:55 Received Downstream TraceMsg (22) len 108: Nov 23 14:26:55 IfIndex (3) len 4: 0 Nov 23 14:26:55 Protocol (1) len 1: BFD Nov 23 14:26:55 Data (9) len 83: (hex) 70 70 6d 64 5f 62 66 64 5f 73 65 6e 64 6d 73 67 20 3a 20 Nov 23 14:26:55 PPM Trace: ppmd_bfd_sendmsg : socket 12 len 24, ifl 78 src 172.16.1.1 dst 172.16.1.2 errno 65 Nov 23 14:26:55 Received Downstream TraceMsg (22) len 93: Nov 23 14:26:55 IfIndex (3) len 4: 0 Nov 23 14:26:55 Protocol (1) len 1: BFD Nov 23 14:26:55 Data (9) len 68: (hex) 42 46 44 20 70 65 72 69 6f 64 69 63 20 78 6d 69 74 20 74
意义
BFD 消息正在写入跟踪文件。