- play_arrow 概述
- play_arrow 基本 BGP 配置
- play_arrow 配置 BGP 会话策略
- play_arrow 为 BGP 启用负载平衡
- play_arrow 为 BGP 配置平滑重启
- play_arrow 为 BGP 会话配置多协议
- play_arrow 配置 BGP CLNS
- play_arrow 对 BGP 网络使用路由反射器和联合
- play_arrow 配置 BGP 安全性
- play_arrow 配置 BGP 路由抖动抑制和错误处理
- play_arrow 配置基于 BGP 的 VPN
- play_arrow Monitoring and Troubleshooting
- play_arrow 配置语句和操作命令
BGP 多跳会话
了解 EBGP 多跳
BGP 是一种外部网关协议 (EGP),用于在不同自治系统中的路由器之间交换路由信息。以下是在路由器之间建立 EBGP 多跳的两种方法:
当外部 BGP (EBGP) 对等方未直接相互连接时,它们必须穿过一个或多个非 BGP 路由器才能相互连接。
配置多跳 EBGP 使对等方能够通过其他路由器以形成对等关系并交换更新消息。当瞻博网络路由设备需要使用不允许直接连接两个 EBGP 对等方的第三方路由器运行 EBGP 时,通常会使用这种类型的配置。EBGP 多跃点可在两个没有直接连接的 EBGP 对等方之间启用邻接方连接。
EBGP 连接的默认行为是使用对等方的物理接口地址通过单个物理跃点进行对等互连。在某些情况下,最好更改此默认的单跃点物理对等 EBGP 行为。其中一种情况是,当多个物理链路连接两个要成为 EBGP 对等方的路由器时。在这种情况下,如果其中一个点对点链路发生故障,备用链路上的可访问性仍然存在。

在图 1 中,路由器 R1 属于 AS 1,路由器 R2 属于 AS 2。路由器之间的两个物理链路用于负载平衡。EBGP 多跃点对等互连也适用于一个物理链路。
以下配置示例有助于在这些多个物理链路之间建立单个 BGP 对等会话:
每个路由器都必须使用远程路由器的环路地址建立对等会话。您可以使用语句
local-address
配置此会话,该语句会更改 BGP 数据包中的对等地址标头信息。使用该
multihop
语句可以更改邻居物理地址的默认用法。此外,您还可以在 BGP 数据包中指定生存时间 (TTL) 值,以控制它们的传播距离。我们使用 TTL 值 1 来确保无法通过网络中的任何其他后门链路建立会话。注:配置多跃点后,默认情况下,Junos OS 会将 TTL 值设置为 64。
TTL 值 1 足以启用到直连邻接方环路地址的 EBGP 会话。
每个路由器都必须具有到远程路由器环路地址的 IP 路由功能。此功能通常是通过使用静态路由将环路地址映射到接口物理地址来实现的。
[edit protocols bgp group ext-peers] type external; local-address 192.168.3.4; neighbor 172.16.128.1 { multihop ttl 1; }
[edit routing-options] static { route 172.16.128.1 next-hop (10.10.1.1 | 10.10.2.1); }
另请参阅
示例:配置 EBGP 多跳会话
此示例说明如何配置与本地路由器相距多个跃点的外部 BGP (EBGP) 对等方。这种类型的会话称为 多跃点 BGP 会话。
要求
在配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
启用多跳 EBGP 会话的配置需要两个 EBGP 对等方之间的连接。此示例使用静态路由在设备之间提供连接。
与语句中通常使用 neighbor
物理地址的直接连接的 EBGP 会话不同,您必须通过指定间接连接的对等方的环路接口地址,将环路接口地址用于多跳 EBGP。这样,EBGP 多跳类似于内部 BGP (IBGP)。
最后,必须添加 multihop
语句。或者,您可以使用语句 ttl
设置最长生存时间 (TTL) 值。TTL 在 BGP 数据包的 IP 报头中携带。如果未指定 TTL 值,则使用系统的默认最大 TTL 值。多跃点 EBGP 会话的默认 TTL 值为 64。另一种选择是通过包含 no-nexthop-change
语句来保留路由播发的 BGP 下一跃点值。
图 2 显示了典型的 EBGP 多跳网络。
设备 C 和设备 E 已建立 EBGP 会话。设备 D 不是启用 BGP 的设备。所有设备都通过静态路由进行连接。

配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中。
设备 C
set interfaces fe-1/2/0 unit 9 description to-D set interfaces fe-1/2/0 unit 9 family inet address 10.10.10.9/30 set interfaces lo0 unit 3 family inet address 192.168.40.4/32 set protocols bgp group external-peers type external set protocols bgp group external-peers multihop ttl 2 set protocols bgp group external-peers local-address 192.168.40.4 set protocols bgp group external-peers export send-static set protocols bgp group external-peers peer-as 18 set protocols bgp group external-peers neighbor 192.168.6.7 set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set routing-options static route 10.10.10.14/32 next-hop 10.10.10.10 set routing-options static route 192.168.6.7/32 next-hop 10.10.10.10 set routing-options router-id 192.168.40.4 set routing-options autonomous-system 17
设备 D
set interfaces fe-1/2/0 unit 10 description to-C set interfaces fe-1/2/0 unit 10 family inet address 10.10.10.10/30 set interfaces fe-1/2/1 unit 13 description to-E set interfaces fe-1/2/1 unit 13 family inet address 10.10.10.13/30 set interfaces lo0 unit 4 family inet address 192.168.6.6/32 set routing-options static route 192.168.40.4/32 next-hop 10.10.10.9 set routing-options static route 192.168.6.7/32 next-hop 10.10.10.14 set routing-options router-id 192.168.6.6
设备 E
set interfaces fe-1/2/0 unit 14 description to-D set interfaces fe-1/2/0 unit 14 family inet address 10.10.10.14/30 set interfaces lo0 unit 5 family inet address 192.168.6.7/32 set protocols bgp group external-peers multihop ttl 2 set protocols bgp group external-peers local-address 192.168.6.7 set protocols bgp group external-peers export send-static set protocols bgp group external-peers peer-as 17 set protocols bgp group external-peers neighbor 192.168.40.4 set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set routing-options static route 10.10.10.8/30 next-hop 10.10.10.13 set routing-options static route 192.168.40.4/32 next-hop 10.10.10.13 set routing-options router-id 192.168.6.7 set routing-options autonomous-system 18
设备 C
分步过程
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 C:
配置直连设备 (to-D) 的接口,并配置环路接口。
content_copy zoom_out_map[edit interfaces fe-1/2/0 unit 9] user@C# set description to-D user@C# set family inet address 10.10.10.9/30 [edit interfaces lo0 unit 3] user@C# set family inet address 192.168.40.4/32
配置与设备 E 的 EBGP 会话。
该
neighbor
语句指向设备 E 上的环路接口。content_copy zoom_out_map[edit protocols bgp group external-peers] user@C# set type external user@C# set local-address 192.168.40.4 user@C# set export send-static user@C# set peer-as 18 user@C# set neighbor 192.168.6.7
配置多跃点语句,使设备 C 和设备 E 成为 EBGP 对等方。
由于对等方彼此相距两个跃点,因此该示例使用该
ttl 2
语句。content_copy zoom_out_map[edit protocols bgp group external-peers] user@C# set multihop ttl 2
使用静态路由配置与设备 E 的连接。
您必须配置到环路接口地址和物理接口上地址的路由。
content_copy zoom_out_map[edit routing-options] user@C# set static route 10.10.10.14/32 next-hop 10.10.10.10 user@C# set static route 192.168.6.7/32 next-hop 10.10.10.10
配置本地路由器 ID 和自治系统 (AS) 编号。
content_copy zoom_out_map[edit routing-options] user@C# set router-id 192.168.40.4 user@C# set autonomous-system 17
配置接受直接路由的策略。
此方案的其他有用选项可能是接受通过 OSPF 或本地路由获知的路由。
content_copy zoom_out_map[edit policy-options policy-statement send-static term 1] user@C# set from protocol static user@C# set then accept
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@C# show interfaces fe-1/2/0 { unit 9 { description to-D; family inet { address 10.10.10.9/30; } } } lo0 { unit 3 { family inet { address 192.168.40.4/32; } } }
user@C# show protocols bgp { group external-peers { type external; multihop { ttl 2; } local-address 192.168.40.4; export send-static; peer-as 18; neighbor 192.168.6.7; } }
user@C# show policy-options policy-statement send-static { term 1 { from protocol static; then accept; } }
user@C# show routing-options static { route 10.10.10.14/32 next-hop 10.10.10.10; route 192.168.6.7/32 next-hop 10.10.10.10; } router-id 192.168.40.4; autonomous-system 17;
如果完成设备配置,请从配置模式输入 commit
。 对拓扑中的所有 BGP 会话重复这些步骤。
配置设备 D
分步过程
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 D:
将 CLI 设置为设备 D。
content_copy zoom_out_mapuser@host> set cli logical-system D
配置直连设备的接口,并配置环路接口。
content_copy zoom_out_map[edit interfaces fe-1/2/0 unit 10] user@D# set description to-C user@D# set family inet address 10.10.10.10/30 [edit interfaces fe-1/2/1 unit 13] user@D# set description to-E user@D# set family inet address 10.10.10.13/30 [edit interfaces lo0 unit 4] user@D# set family inet address 192.168.6.6/32
使用到环路接口地址的静态路由配置与其他设备的连接。
在设备 D 上,不需要到物理地址的静态路由,因为设备 D 直接连接到设备 C 和设备 E。
content_copy zoom_out_map[edit routing-options] user@D# set static route 192.168.40.4/32 next-hop 10.10.10.9 user@D# set static route 192.168.6.7/32 next-hop 10.10.10.14
配置本地路由器 ID。
content_copy zoom_out_map[edit routing-options] user@D# set router-id 192.168.6.6
结果
在配置模式下,输入 show interfaces
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@D# show interfaces fe-1/2/0 { unit 10 { description to-C; family inet { address 10.10.10.10/30; } } } fe-1/2/1 { unit 13 { description to-E; family inet { address 10.10.10.13/30; } } } lo0 { unit 4 { family inet { address 192.168.6.6/32; } } }
user@D# show protocols
user@D# show routing-options static { route 192.168.40.4/32 next-hop 10.10.10.9; route 192.168.6.7/32 next-hop 10.10.10.14; } router-id 192.168.6.6;
如果完成设备配置,请从配置模式输入 commit
。 对拓扑中的所有 BGP 会话重复这些步骤。
配置设备 E
分步过程
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置设备 E:
将 CLI 设置为设备 E。
content_copy zoom_out_mapuser@host> set cli logical-system E
配置直连设备 (to-D) 的接口,并配置环路接口。
content_copy zoom_out_map[edit interfaces fe-1/2/0 unit 14] user@E# set description to-D user@E# set family inet address 10.10.10.14/30 [edit interfaces lo0 unit 5] user@E# set family inet address 192.168.6.7/32
配置与设备 E 的 EBGP 会话。
该
neighbor
语句指向设备 C 上的环路接口。content_copy zoom_out_map[edit protocols bgp group external-peers] user@E# set local-address 192.168.6.7 user@E# set export send-static user@E# set peer-as 17 user@E# set neighbor 192.168.40.4
配置语句以使
multihop
设备 C 和设备 E 成为 EBGP 对等方。由于对等方彼此相距两个跃点,因此该示例使用该
ttl 2
语句。content_copy zoom_out_map[edit protocols bgp group external-peers] user@E# set multihop ttl 2
使用静态路由配置与设备 E 的连接。
您必须配置到环路接口地址和物理接口上地址的路由。
content_copy zoom_out_map[edit routing-options] user@E# set static route 10.10.10.8/30 next-hop 10.10.10.13 user@E# set static route 192.168.40.4/32 next-hop 10.10.10.13
配置本地路由器 ID 和自治系统 (AS) 编号。
content_copy zoom_out_map[edit routing-options] user@E# set router-id 192.168.6.7 user@E# set autonomous-system 18
配置接受直接路由的策略。
此方案的其他有用选项可能是接受通过 OSPF 或本地路由获知的路由。
content_copy zoom_out_map[edit policy-options policy-statement send-static term 1] user@E# set from protocol static user@E# set then accept
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@E# show interfaces fe-1/2/0 { unit 14 { description to-D; family inet { address 10.10.10.14/30; } } } lo0 { unit 5 { family inet { address 192.168.6.7/32; } } }
user@E# show protocols bgp { group external-peers { multihop { ttl 2; } local-address 192.168.6.7; export send-static; peer-as 17; neighbor 192.168.40.4; } }
user@E# show policy-options policy-statement send-static { term 1 { from protocol static; then accept; } }
user@E# show routing-options static { route 10.10.10.8/30 next-hop 10.10.10.13; route 192.168.40.4/32 next-hop 10.10.10.13; } router-id 192.168.6.7; autonomous-system 18;
如果完成设备配置,请从配置模式输入 commit
。
验证
确认配置工作正常。
验证连接
目的
确保设备 C 可以 ping 设备 E,并将环路接口地址指定为 ping 请求的源。
环路接口地址是 BGP 将使用的源地址。
操作
在操作模式下,从设备 C 输入 ping 10.10.10.14 source 192.168.40.4
命令,然后从设备 E 输入 ping 10.10.10.9 source 192.168.6.7
命令。
user@C> ping 10.10.10.14 source 192.168.40.4 PING 10.10.10.14 (10.10.10.14): 56 data bytes 64 bytes from 10.10.10.14: icmp_seq=0 ttl=63 time=1.262 ms 64 bytes from 10.10.10.14: icmp_seq=1 ttl=63 time=1.202 ms ^C --- 10.10.10.14 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 1.202/1.232/1.262/0.030 ms
user@E> ping 10.10.10.9 source 192.168.6.7 PING 10.10.10.9 (10.10.10.9): 56 data bytes 64 bytes from 10.10.10.9: icmp_seq=0 ttl=63 time=1.255 ms 64 bytes from 10.10.10.9: icmp_seq=1 ttl=63 time=1.158 ms ^C --- 10.10.10.9 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 1.158/1.206/1.255/0.049 ms
意义
如果 ping 有效,则静态路由将正常工作。
验证是否已建立 BGP 会话
目的
验证 BGP 会话是否已启动。
操作
在操作模式下,输入 show bgp summary
命令。
user@C> show bgp summary Groups: 1 Peers: 1 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 2 0 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 192.168.6.7 18 147 147 0 1 1:04:27 0/2/2/0 0/0/0/0
user@E> show bgp summary Groups: 1 Peers: 1 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 2 0 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 192.168.40.4 17 202 202 0 1 1:02:18 0/2/2/0 0/0/0/0
意义
输出显示两个设备各有一个对等方。没有对等方停机。
查看播发的路线
目的
检查以确保 BGP 正在播发路由。
操作
在操作模式下,输入 show route advertising-protocol bgp neighbor
命令。
user@E> show route advertising-protocol bgp 192.168.6.7 inet.0: 5 destinations, 7 routes (5 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.10.10.14/32 Self I * 192.168.6.7/32 Self I
user@C> show route advertising-protocol bgp 192.168.40.4 inet.0: 5 destinations, 7 routes (5 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.10.10.8/30 Self I * 192.168.40.4/32 Self I
意义
send-static
路由策略将静态路由从路由表导出到 BGP。BGP 在对等方之间播发这些路由,因为已建立 BGP 对等会话。