添加启用 MD5 的 BGP 邻居
问题
一些组织出于安全原因或因为现有合作伙伴要求 MD5 而在 BGP 上使用 MD5。本文介绍如何启用它。
环境
- Cumulus Linux 2.1 及更高版本。
- 本文假设您正在使用 FRR 作为您的路由平台。设置包括两个交换机 AS 65000 和 65001,通过链路 192.0.2.100/30 连接。
解决方案
您可以通过以下两种方式之一为您的 BGP 邻居启用 MD5
- 使用 FRR 的模态 CLI,
vtysh。 - 通过手动编辑 Cumulus Linux 中的
frr.conf配置文件。
在您启用 MD5 之前,switch1 的配置如下所示
frr# show ip bgp sum
BGP router identifier 192.0.2.2, local AS number 65001
RIB entries 0, using 0 bytes of memory
Peers 1, using 6652 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.102 4 65000 2 3 0 0 0 00:00:04 0
Total number of neighbors 1
switch2 的配置如下所示
frr# sho ip bgp sum
BGP router identifier 192.0.2.5, local AS number 65000
RIB entries 0, using 0 bytes of memory
Peers 1, using 6652 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.101 4 65001 2 3 0 0 0 00:00:49 0
Total number of neighbors 1
使用 vtysh 启用 MD5
SSH 进入 switch1。
运行
sudo vtysh。运行这些 FRR 命令
frr# configure terminal frr(config)# router bgp 65000 frr(config-router)# neighbor 192.0.2.101 password mypasswordSSH 进入 switch2,然后运行这些 FRR 命令
frr# configure terminal frr(config)# router bgp 65001 frr(config-router)# neighbor 192.0.2.102 password mypassword当您正确配置双方后,BGP 应该会自动重新建立;在每台交换机上使用
show ip bgp summary进行确认。以下是来自 switch2 的输出frr# show ip bgp summary BGP router identifier 192.0.2.5, local AS number 65000 RIB entries 0, using 0 bytes of memory Peers 1, using 6652 bytes of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.0.2.101 4 65001 257 284 0 0 0 00:08:11 0 Total number of neighbors 1如果您希望此配置在 FRR 重启后仍然存在,请在每台交换机上运行
write memory。
通过手动编辑配置启用 MD5
SSH 进入 switch1。
使用文本编辑器(本文假设您正在使用
vi),编辑frr.conf。运行
vi /etc/frr/frr.conf。如果您正在运行 Cumulus Linux 2.0,则运行sudo vi /etc/frr/frr.conf。在
/bgp下查找 switch1 的 BGP 配置router bgp 65000 bgp router-id 192.0.2.2 neighbor 192.0.2.101 remote-as 65001进入插入模式,然后添加以下行
neighbor 192.0.2.101 password mypassword保存并退出 (
:wq!)。重启 FRR (
sudo systemctl restart frr)。这将拆除任何其他第 3 层会话并影响网络流量。
使用
net show bgp summary确认这已生效cumulus@switch:~$ net show bgp summary BGP router identifier 192.0.2.2, local AS number 65001 RIB entries 0, using 0 bytes of memory Peers 1, using 6652 bytes of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.0.2.102 4 65000 200 227 0 0 0 00:00:03 0 Total number of neighbors 1SSH 进入 switch2,然后在那里编辑
frr.confvi /etc/frr/frr.conf如果您正在运行 Cumulus Linux 2.0 或更高版本
sudo vi /etc/frr/frr.conf在
/bgp下查找 switch2 的 BGP 配置router bgp 65001 bgp router-id 192.0.2.5 neighbor 192.0.2.102 remote-as 65000进入插入模式,然后添加以下行
neighbor 192.0.2.102 password mypassword保存并退出 (
:wq!)。重启 FRR (
sudo systemctl restart frr)。这将拆除任何其他第 3 层会话并影响网络流量。
使用
net show bgp summary确认这已生效BGP router identifier 192.0.2.5, local AS number 65000 RIB entries 0, using 0 bytes of memory Peers 1, using 6652 bytes of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.0.2.101 4 65001 255 282 0 0 0 00:06:29 0 Total number of neighbors 1