BGP 多跳会话
了解 EBGP 多跳
BGP 是一种外部网关协议 (EGP),用于在不同自治系统 (AS) 中的路由器之间交换路由信息。以下是在路由器之间建立 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) 的接口,并配置环路接口。
[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 上的环路接口。[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
语句。[edit protocols bgp group external-peers] user@C# set multihop ttl 2
使用静态路由配置与设备 E 的连接。
您必须同时配置到环路接口地址和物理接口上地址的路由。
[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) 编号。
[edit routing-options] user@C# set router-id 192.168.40.4 user@C# set autonomous-system 17
配置接受直接路由的策略。
此方案的其他有用选项可能是接受通过 OSPF 或本地路由获知的路由。
[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。
user@host> set cli logical-system D
配置直连设备的接口,然后配置环路接口。
[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。
[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。
[edit routing-options] user@D# set router-id 192.168.6.6
结果
在配置模式下,输入和 show routing-options
命令以确认show interfaces
您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以更正配置。
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。
user@host> set cli logical-system E
配置直连设备 (to-D) 的接口,并配置环路接口。
[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 上的环路接口。[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
语句。[edit protocols bgp group external-peers] user@E# set multihop ttl 2
使用静态路由配置与设备 E 的连接。
您必须同时配置到环路接口地址和物理接口上地址的路由。
[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) 编号。
[edit routing-options] user@E# set router-id 192.168.6.7 user@E# set autonomous-system 18
配置接受直接路由的策略。
此方案的其他有用选项可能是接受通过 OSPF 或本地路由获知的路由。
[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 对等方会话已建立。