示例:在 BGP 中通告多条路径
在此示例中,BGP 路由器配置为播发多个路径,而不是仅播发活动路径。RFC 7911, BGP 中的多路径播发中指定了 BGP 中的多条路径播发。
要求
此示例使用以下硬件和软件组件:
八个支持 BGP 的设备。
启用 BGP 的设备中有五台不一定需要是路由器。例如,它们可以是 EX 系列以太网交换机。
其中三个支持 BGP 的设备配置为发送多个路径或接收多个路径(或同时发送和接收多个路径)。这三台支持 BGP 的设备必须是 M 系列多服务边缘路由器、MX 系列 5G 通用路由平台或 T 系列核心路由器。
这三台路由器必须运行 Junos OS 11.4 或更高版本。
概述
以下语句用于配置到目标的多个路径:
[edit protocols bgp group group-name family family] add-path { receive; send { include-backup-path include-backup-path; multipath; path-count path-count; path-selection-mode { (all-paths | equal-cost-paths); } prefix-policy [ policy-names ... ]; } }
在此示例中,路由器 R5、路由器 R6 和路由器 R7 将静态路由重新分发到 BGP 中。路由器 R1 和路由器 R4 是路由反射器。路由器 R2 和路由器 R3 是路由反射器 R1 的客户端。路由器 R8 是路由反射器 R4 的客户端。
在 BGP 中启用多路径通告时,路由反射是可选的。
通过此 add-path send path-count 6
配置,路由器 R1 配置为向路由器 R4 发送最多 6 条路径(每个目标)。
通过此 add-path receive
配置,路由器 R4 配置为从路由器 R1 接收多条路径。
通过此 add-path send path-count 6
配置,路由器 R4 配置为向路由器 R8 发送最多 6 条路径。
通过此 add-path receive
配置,路由器 R8 配置为从路由器 R4 接收多条路径。
策略配置(以及相应的路由过滤器)将 add-path send prefix-policy allow_199
路由器 R4 限制为仅发送 172.16.199.1/32 路由的多个路径。
配置
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中。
路由器 R1
set interfaces fe-0/0/0 unit 12 family inet address 10.0.12.1/24 set interfaces fe-0/0/1 unit 13 family inet address 10.0.13.1/24 set interfaces fe-1/0/0 unit 14 family inet address 10.0.14.1/24 set interfaces fe-1/2/0 unit 15 family inet address 10.0.15.1/24 set interfaces lo0 unit 10 family inet address 10.0.0.10/32 set protocols bgp group rr type internal set protocols bgp group rr local-address 10.0.0.10 set protocols bgp group rr cluster 10.0.0.10 set protocols bgp group rr neighbor 10.0.0.20 set protocols bgp group rr neighbor 10.0.0.30 set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.15.2 local-address 10.0.15.1 set protocols bgp group e1 neighbor 10.0.15.2 peer-as 2 set protocols bgp group rr_rr type internal set protocols bgp group rr_rr local-address 10.0.0.10 set protocols bgp group rr_rr neighbor 10.0.0.40 family inet unicast add-path send path-count 6 set protocols ospf area 0.0.0.0 interface lo0.10 passive set protocols ospf area 0.0.0.0 interface fe-0/0/0.12 set protocols ospf area 0.0.0.0 interface fe-0/0/1.13 set protocols ospf area 0.0.0.0 interface fe-1/0/0.14 set protocols ospf area 0.0.0.0 interface fe-1/2/0.15 set routing-options router-id 10.0.0.10 set routing-options autonomous-system 1
路由器 R2
set interfaces fe-1/2/0 unit 21 family inet address 10.0.12.2/24 set interfaces fe-1/2/1 unit 26 family inet address 10.0.26.1/24 set interfaces lo0 unit 20 family inet address 10.0.0.20/32 set protocols bgp group rr type internal set protocols bgp group rr local-address 10.0.0.20 set protocols bgp group rr neighbor 10.0.0.10 export set_nh_self set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.26.2 peer-as 2 set protocols ospf area 0.0.0.0 interface lo0.20 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.21 set protocols ospf area 0.0.0.0 interface fe-1/2/1.28 set policy-options policy-statement set_nh_self then next-hop self set routing-options autonomous-system 1
路由器 R3
set interfaces fe-1/0/1 unit 31 family inet address 10.0.13.2/24 set interfaces fe-1/0/2 unit 37 family inet address 10.0.37.1/24 set interfaces lo0 unit 30 family inet address 10.0.0.30/32 set protocols bgp group rr type internal set protocols bgp group rr local-address 10.0.0.30 set protocols bgp group rr neighbor 10.0.0.10 export set_nh_self set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.37.2 peer-as 2 set protocols ospf area 0.0.0.0 interface lo0.30 passive set protocols ospf area 0.0.0.0 interface fe-1/0/1.31 set protocols ospf area 0.0.0.0 interface fe-1/0/2.37 set policy-options policy-statement set_nh_self then next-hop self set routing-options autonomous-system 1
路由器 R4
set interfaces fe-1/2/0 unit 41 family inet address 10.0.14.2/24 set interfaces fe-1/2/1 unit 48 family inet address 10.0.48.1/24 set interfaces lo0 unit 40 family inet address 10.0.0.40/32 set protocols bgp group rr type internal set protocols bgp group rr local-address 10.0.0.40 set protocols bgp group rr family inet unicast add-path receive set protocols bgp group rr neighbor 10.0.0.10 set protocols bgp group rr_client type internal set protocols bgp group rr_client local-address 10.0.0.40 set protocols bgp group rr_client cluster 10.0.0.40 set protocols bgp group rr_client neighbor 10.0.0.80 family inet unicast add-path send path-count 6 set protocols bgp group rr_client neighbor 10.0.0.80 family inet unicast add-path send prefix-policy allow_199 set protocols ospf area 0.0.0.0 interface fe-1/2/0.41 set protocols ospf area 0.0.0.0 interface lo0.40 passive set protocols ospf area 0.0.0.0 interface fe-1/2/1.48 set policy-options policy-statement allow_199 from route-filter 172.16.199.1/32 exact set policy-options policy-statement allow_199 term match_199 from prefix-list match_199 set policy-options policy-statement allow_199 then add-path send-count 20 set policy-options policy-statement allow_199 then accept set routing-options autonomous-system 1
路由器 R5
set interfaces fe-1/2/0 unit 51 family inet address 10.0.15.2/24 set interfaces lo0 unit 50 family inet address 10.0.0.50/32 set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.15.1 export s2b set protocols bgp group e1 neighbor 10.0.15.1 peer-as 1 set policy-options policy-statement s2b from protocol static set policy-options policy-statement s2b from protocol direct set policy-options policy-statement s2b then as-path-expand 2 set policy-options policy-statement s2b then accept set routing-options autonomous-system 2 set routing-options static route 172.16.199.1/32 reject set routing-options static route 172.16.198.1/32 reject
路由器 R6
set interfaces fe-1/2/0 unit 62 family inet address 10.0.26.2/24 set interfaces lo0 unit 60 family inet address 10.0.0.60/32 set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.26.1 export s2b set protocols bgp group e1 neighbor 10.0.26.1 peer-as 1 set policy-options policy-statement s2b from protocol static set policy-options policy-statement s2b from protocol direct set policy-options policy-statement s2b then accept set routing-options autonomous-system 2 set routing-options static route 172.16.199.1/32 reject set routing-options static route 172.16.198.1/32 reject
路由器 R7
set interfaces fe-1/2/0 unit 73 family inet address 10.0.37.2/24 set interfaces lo0 unit 70 family inet address 10.0.0.70/32 set protocols bgp group e1 type external set protocols bgp group e1 neighbor 10.0.37.1 export s2b set protocols bgp group e1 neighbor 10.0.37.1 peer-as 1 set policy-options policy-statement s2b from protocol static set policy-options policy-statement s2b from protocol direct set policy-options policy-statement s2b then accept set routing-options autonomous-system 2 set routing-options static route 172.16.199.1/32 reject
路由器 R8
set interfaces fe-1/2/0 unit 84 family inet address 10.0.48.2/24 set interfaces lo0 unit 80 family inet address 10.0.0.80/32 set protocols bgp group rr type internal set protocols bgp group rr local-address 10.0.0.80 set protocols bgp group rr neighbor 10.0.0.40 family inet unicast add-path receive set protocols ospf area 0.0.0.0 interface lo0.80 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.84 set routing-options autonomous-system 1
配置路由器 R1
分步过程
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置路由器 R1:
配置路由器 R2、路由器 R3、路由器 R4 和路由器 R5 的接口,并配置环路 (lo0) 接口。
[edit interfaces] user@R1# set fe-0/0/0 unit 12 family inet address 10.0.12.1/24 user@R1# set fe-0/0/1 unit 13 family inet address 10.0.13.1/24 user@R1# set fe-1/0/0 unit 14 family inet address 10.0.14.1/24 user@R1# set fe-1/2/0 unit 15 family inet address 10.0.15.1/24 user@R1#set lo0 unit 10 family inet address 10.0.0.10/32
在接口上配置 BGP,并配置 IBGP 路由反射。
[edit protocols bgp] user@R1# set group rr type internal user@R1# set group rr local-address 10.0.0.10 user@R1# set group rr cluster 10.0.0.10 user@R1# set group rr neighbor 10.0.0.20 user@R1# set group rr neighbor 10.0.0.30 user@R1# set group rr_rr type internal user@R1# set group rr_rr local-address 10.0.0.10 user@R1# set group e1 type external user@R1# set group e1 neighbor 10.0.15.2 local-address 10.0.15.1 user@R1# set group e1 neighbor 10.0.15.2 peer-as 2
将路由器 R1 配置为向其邻居路由器 R4 发送最多六条路径。
路径的目标可以是路由器 R1 可以通过多个路径到达的任何目标。
[edit protocols bgp] user@R1# set group rr_rr neighbor 10.0.0.40 family inet unicast add-path send path-count 6
在接口上配置 OSPF。
[edit protocols ospf] user@R1# set area 0.0.0.0 interface lo0.10 passive user@R1# set area 0.0.0.0 interface fe-0/0/0.12 user@R1# set area 0.0.0.0 interface fe-0/0/1.13 user@R1# set area 0.0.0.0 interface fe-1/0/0.14 user@R1# set area 0.0.0.0 interface fe-1/2/0.15
配置路由器 ID 和自治系统编号。
[edit routing-options] user@R1# set router-id 10.0.0.10 user@R1# set autonomous-system 1
如果完成设备配置,请提交配置。
user@R1# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R1# show interfaces fe-0/0/0 { unit 12 { family inet { address 10.0.12.1/24; } } } fe-0/0/1 { unit 13 { family inet { address 10.0.13.1/24; } } } fe-1/0/0 { unit 14 { family inet { address 10.0.14.1/24; } } } fe-1/2/0 { unit 15 { family inet { address 10.0.15.1/24; } } } lo0 { unit 10 { family inet { address 10.0.0.10/32; } } }
user@R1# show protocols bgp { group rr { type internal; local-address 10.0.0.10; cluster 10.0.0.10; neighbor 10.0.0.20; neighbor 10.0.0.30; } group e1 { type external; neighbor 10.0.15.2 { local-address 10.0.15.1; peer-as 2; } } group rr_rr { type internal; local-address 10.0.0.10; neighbor 10.0.0.40 { family inet { unicast { add-path { send { path-count 6; } } } } } } } ospf { area 0.0.0.0 { interface lo0.10 { passive; } interface fe-0/0/0.12; interface fe-0/0/1.13; interface fe-1/0/0.14; interface fe-1/2/0.15; } }
user@R1# show routing-options router-id 10.0.0.10; autonomous-system 1;
配置路由器 R2
分步过程
要配置路由器 R2:
配置环路 (lo0) 接口以及路由器 R6 和路由器 R1 的接口。
[edit interfaces] user@R2# set fe-1/2/0 unit 21 family inet address 10.0.12.2/24 user@R2# set fe-1/2/1 unit 26 family inet address 10.0.26.1/24 user@R2# set lo0 unit 20 family inet address 10.0.0.20/32
在路由器 R2 的接口上配置 BGP 和 OSPF。
[edit protocols] user@R2# set bgp group rr type internal user@R2# set bgp group rr local-address 10.0.0.20 user@R2# set bgp group e1 type external user@R2# set bgp group e1 neighbor 10.0.26.2 peer-as 2 user@R2# set ospf area 0.0.0.0 interface lo0.20 passive user@R2# set ospf area 0.0.0.0 interface fe-1/2/0.21 user@R2# set ospf area 0.0.0.0 interface fe-1/2/1.28
对于从路由器 R2 发送到路由器 R1 的路由,请将路由器 R2 播发为下一跃点,因为路由器 R1 在 10.0.26.0/24 网络上没有到路由器 R6 地址的路由。
[edit] user@R2# set policy-options policy-statement set_nh_self then next-hop self user@R2# set protocols bgp group rr neighbor 10.0.0.10 export set_nh_self
配置自治系统编号。
[edit] user@R2# set routing-options autonomous-system 1
如果完成设备配置,请提交配置。
user@R2# commit
结果
在配置模式下,输入 show interfaces
、 show protocols
、 show policy-options
和 show routing-options
命令确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R2# show interfaces fe-1/2/0 { unit 21 { family inet { address 10.0.12.2/24; } } } fe-1/2/1 { unit 26 { family inet { address 10.0.26.1/24; } } } lo0 { unit 20 { family inet { address 10.0.0.20/32; } } }
user@R2# show protocols bgp { group rr { type internal; local-address 10.0.0.20; neighbor 10.0.0.10 { export set_nh_self; } } group e1 { type external; neighbor 10.0.26.2 { peer-as 2; } } } ospf { area 0.0.0.0 { interface lo0.20 { passive; } interface fe-1/2/0.21; interface fe-1/2/1.28; } }
user@R2# show policy-options policy-statement set_nh_self { then { next-hop self; } }
user@R2# show routing-options autonomous-system 1;
配置路由器 R3
分步过程
要配置路由器 R3:
配置环路 (lo0) 接口以及路由器 R7 和路由器 R1 的接口。
[edit interfaces] user@R3# set fe-1/0/1 unit 31 family inet address 10.0.13.2/24 user@R3# set fe-1/0/2 unit 37 family inet address 10.0.37.1/24 user@R3# set lo0 unit 30 family inet address 10.0.0.30/32
在路由器 R3 的接口上配置 BGP 和 OSPF。
[edit protocols] user@R3# set bgp group rr type internal user@R3# set bgp group rr local-address 10.0.0.30 user@R3# set bgp group e1 type external user@R3# set bgp group e1 neighbor 10.0.37.2 peer-as 2 user@R3# set ospf area 0.0.0.0 interface lo0.30 passive user@R3# set ospf area 0.0.0.0 interface fe-1/0/1.31 user@R3# set ospf area 0.0.0.0 interface fe-1/0/2.37
对于从路由器 R3 发送到路由器 R1 的路由,请将路由器 R3 播发为下一跃点,因为路由器 R1 在 10.0.37.0/24 网络上没有到路由器 R7 地址的路由。
[edit] user@R3# set policy-options policy-statement set_nh_self then next-hop self user@R3# set protocols bgp group rr neighbor 10.0.0.10 export set_nh_self
配置自治系统编号。
[edit] user@R3# set routing-options autonomous-system 1
如果完成设备配置,请提交配置。
user@R3# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R3# show interfaces fe-1/0/1 { unit 31 { family inet { address 10.0.13.2/24; } } } fe-1/0/2 { unit 37 { family inet { address 10.0.37.1/24; } } } lo0 { unit 30 { family inet { address 10.0.0.30/32; } } }
user@R3# show protocols bgp { group rr { type internal; local-address 10.0.0.30; neighbor 10.0.0.10 { export set_nh_self; } } group e1 { type external; neighbor 10.0.37.2 { peer-as 2; } } } ospf { area 0.0.0.0 { interface lo0.30 { passive; } interface fe-1/0/1.31; interface fe-1/0/2.37; } } user@R3# show policy-options policy-statement set_nh_self { then { next-hop self; } }
user@R3# show routing-options autonomous-system 1;
配置路由器 R4
分步过程
要配置路由器 R4:
配置路由器 R1 和路由器 R8 的接口,并配置环路 (lo0) 接口。
[edit interfaces] user@R4# set fe-1/2/0 unit 41 family inet address 10.0.14.2/24 user@R4# set fe-1/2/1 unit 48 family inet address 10.0.48.1/24 user@R4# set lo0 unit 40 family inet address 10.0.0.40/32
在接口上配置 BGP,并配置 IBGP 路由反射。
[edit protocols bgp] user@R4# set group rr type internal user@R4# set group rr local-address 10.0.0.40 user@R4# set group rr neighbor 10.0.0.10 user@R4# set group rr_client type internal user@R4# set group rr_client local-address 10.0.0.40 user@R4# set group rr_client cluster 10.0.0.40
将路由器 R4 配置为向其邻居路由器 R8 发送最多 6 条路径。
路径的目的地可以是路由器 R4 可以通过多个路径到达的任何目标。
[edit protocols bgp] user@R4# set group rr_client neighbor 10.0.0.80 family inet unicast add-path send path-count 6
将路由器 R4 配置为从其邻居路由器 R1 接收多条路径。
路径的目标可以是路由器 R1 可以通过多个路径到达的任何目标。
[edit protocols bgp group rr family inet unicast] user@R4# set add-path receive
在接口上配置 OSPF。
[edit protocols ospf area 0.0.0.0] user@R4# set interface fe-1/2/0.41 user@R4# set interface lo0.40 passive user@R4# set interface fe-1/2/1.48
配置允许路由器 R4 将路由器 R8 多个路径发送到 172.16.199.1/32 路由的策略。
路由器 R4 接收 172.16.198.1/32 路由和 172.16.199.1/32 路由的多条路径。但是,由于此策略,路由器 R4 仅发送 172.16.199.1/32 路由的多个路径。
[edit protocols bgp group rr_client neighbor 10.0.0.80 family inet unicast] user@R4# set add-path send prefix-policy allow_199 [edit policy-options policy-statement allow_199] user@R4# set from route-filter 172.16.199.1/32 exact user@R4# set then accept
路由器 R4 还可以配置为为添加路径播发前缀的子集发送多达 20 个 BGP
add-path
路由。[edit policy-options policy-statement allow_199] user@R4# set term match_199 from prefix-list match_199 user@R4# set then add-path send-count 20
配置自治系统编号。
[edit routing-options] user@R4# set autonomous-system 1
如果完成设备配置,请提交配置。
user@R4# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R4# show interfaces fe-1/2/0 { unit 41 { family inet { address 10.0.14.2/24; } } } fe-1/2/1 { unit 48 { family inet { address 10.0.48.1/24; } } } lo0 { unit 40 { family inet { address 10.0.0.40/32; } } }
user@R4# show protocols bgp { group rr { type internal; local-address 10.0.0.40; family inet { unicast { add-path { receive; } } } neighbor 10.0.0.10; } group rr_client { type internal; local-address 10.0.0.40; cluster 10.0.0.40; neighbor 10.0.0.80 { family inet { unicast { add-path { send { path-count 6; prefix-policy allow_199; } } } } } } } ospf { area 0.0.0.0 { interface lo0.40 { passive; } interface fe-1/2/0.41; interface fe-1/2/1.48; } }
user@R4# show policy-options policy-statement allow_199 { from { route-filter 172.16.199.1/32 exact; } from term match_199 { prefix-list match_199; } then add-path send-count 20; then accept; }
user@R4# show routing-options autonomous-system 1;
配置路由器 R5
分步过程
要配置路由器 R5:
配置环路 (lo0) 接口和路由器 R1 接口。
[edit interfaces] user@R5# set fe-1/2/0 unit 51 family inet address 10.0.15.2/24 user@R5# set lo0 unit 50 family inet address 10.0.0.50/32
在路由器 R5 的接口上配置 BGP。
[edit protocols bgp group e1] user@R5# set type external user@R5# set neighbor 10.0.15.1 peer-as 1
创建静态路由以重新分发到 BGP。
[edit routing-options] user@R5# set static route 172.16.199.1/32 reject user@R5# set static route 172.16.198.1/32 reject
将静态和直接路由重新分发到 BGP 中。
[edit protocols bgp group e1 neighbor 10.0.15.1] user@R5# set export s2b [edit policy-options policy-statement s2b] user@R5# set from protocol static user@R5# set from protocol direct user@R5# set then as-path-expand 2 user@R5# set then accept
配置自治系统编号。
[edit routing-options] user@R5# set autonomous-system 2
如果完成设备配置,请提交配置。
user@R5# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R5# show interfaces fe-1/2/0 { unit 51 { family inet { address 10.0.15.2/24; } } } lo0 { unit 50 { family inet { address 10.0.0.50/32; } } }
user@R5# show protocols bgp { group e1 { type external; neighbor 10.0.15.1 { export s2b; peer-as 1; } } }
user@R5# show policy-options policy-statement s2b { from protocol [ static direct ]; then { as-path-expand 2; accept; } }
user@R5# show routing-options static { route 172.16.198.1/32 reject; route 172.16.199.1/32 reject; } autonomous-system 2;
配置路由器 R6
分步过程
要配置路由器 R6:
配置环路 (lo0) 接口和路由器 R2 接口。
[edit interfaces] user@R6# set fe-1/2/0 unit 62 family inet address 10.0.26.2/24 user@R6# set lo0 unit 60 family inet address 10.0.0.60/32
在路由器 R6 的接口上配置 BGP。
[edit protocols] user@R6# set bgp group e1 type external user@R6# set bgp group e1 neighbor 10.0.26.1 peer-as 1
创建静态路由以重新分发到 BGP。
[edit] user@R6# set routing-options static route 172.16.199.1/32 reject user@R6# set routing-options static route 172.16.198.1/32 reject
将来自路由器 R6 路由表的静态和直接路由重新分配到 BGP。
[edit protocols bgp group e1 neighbor 10.0.26.1] user@R6# set export s2b [edit policy-options policy-statement s2b] user@R6# set from protocol static user@R6# set from protocol direct user@R6# set then accept
配置自治系统编号。
[edit routing-options] user@R6# set autonomous-system 2
如果完成设备配置,请提交配置。
user@R6# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R6# show interfaces fe-1/2/0 { unit 62 { family inet { address 10.0.26.2/24; } } } lo0 { unit 60 { family inet { address 10.0.0.60/32; } } }
user@R6# show protocols bgp { group e1 { type external; neighbor 10.0.26.1 { export s2b; peer-as 1; } } }
user@R6# show policy-options policy-statement s2b { from protocol [ static direct ]; then accept; }
user@R6# show routing-options static { route 172.16.198.1/32 reject; route 172.16.199.1/32 reject; } autonomous-system 2;
配置路由器 R7
分步过程
要配置路由器 R7:
配置环路 (lo0) 接口和路由器 R3 接口。
[edit interfaces] user@R7# set fe-1/2/0 unit 73 family inet address 10.0.37.2/24 user@R7# set lo0 unit 70 family inet address 10.0.0.70/32
在路由器 R7 的接口上配置 BGP。
[edit protocols bgp group e1] user@R7# set type external user@R7# set neighbor 10.0.37.1 peer-as 1
创建静态路由以重新分发到 BGP。
[edit] user@R7# set routing-options static route 172.16.199.1/32 reject
将来自路由器 R7 路由表的静态和直接路由重新分发到 BGP 中。
[edit protocols bgp group e1 neighbor 10.0.37.1] user@R7# set export s2b [edit policy-options policy-statement s2b] user@R7# set from protocol static user@R7# set from protocol direct user@R7# set then accept
配置自治系统编号。
[edit routing-options] user@R7# set autonomous-system 2
如果完成设备配置,请提交配置。
user@R7# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R7# show interfaces fe-1/2/0 { unit 73 { family inet { address 10.0.37.2/24; } } } lo0 { unit 70 { family inet { address 10.0.0.70/32; } } }
user@R7# show protocols bgp { group e1 { type external; neighbor 10.0.37.1 { export s2b; peer-as 1; } } }
user@R7# show policy-options policy-statement s2b { from protocol [ static direct ]; then accept; }
user@R7# show routing-options static { route 172.16.199.1/32 reject; } autonomous-system 2;
配置路由器 R8
分步过程
要配置路由器 R8:
配置环路 (lo0) 接口和路由器 R4 接口。
[edit interfaces] user@R8# set fe-1/2/0 unit 84 family inet address 10.0.48.2/24 user@R8# set lo0 unit 80 family inet address 10.0.0.80/32
在路由器 R8 的接口上配置 BGP 和 OSPF。
[edit protocols] user@R8# set bgp group rr type internal user@R8# set bgp group rr local-address 10.0.0.80 user@R8# set ospf area 0.0.0.0 interface lo0.80 passive user@R8# set ospf area 0.0.0.0 interface fe-1/2/0.84
将路由器 R8 配置为从其邻居路由器 R4 接收多条路径。
路径的目的地可以是路由器 R4 可以通过多个路径到达的任何目标。
[edit protocols] user@R8# set bgp group rr neighbor 10.0.0.40 family inet unicast add-path receive
配置自治系统编号。
[edit] user@R8# set routing-options autonomous-system 1
如果完成设备配置,请提交配置。
user@R8# commit
结果
在配置模式下,输入 show interfaces
、show protocols
、show policy-options
和 show routing-options
命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R8# show interfaces fe-1/2/0 { unit 84 { family inet { address 10.0.48.2/24; } } } lo0 { unit 80 { family inet { address 10.0.0.80/32; } } }
user@R8# show protocols bgp { group rr { type internal; local-address 10.0.0.80; neighbor 10.0.0.40 { family inet { unicast { add-path { receive; } } } } } } ospf { area 0.0.0.0 { interface lo0.80 { passive; } interface fe-1/2/0.84; } }
user@R8# show routing-options autonomous-system 1;
验证
确认配置工作正常。
验证 BGP 对等方是否能够发送和接收多条路径
目的
确保命令输出 show bgp neighbor
中出现以下一个或两个字符串:
NLRI's for which peer can receive multiple paths: inet-unicast
NLRI's for which peer can send multiple paths: inet-unicast
操作
user@R1> show bgp neighbor 10.0.0.40 Peer: 10.0.0.40+179 AS 1 Local: 10.0.0.10+64227 AS 1 Type: Internal State: Established Flags: <Sync> ... NLRI's for which peer can receive multiple paths: inet-unicast ...
user@R4> show bgp neighbor 10.0.0.10 Peer: 10.0.0.10+64227 AS 1 Local: 10.0.0.40+179 AS 1 Type: Internal State: Established Flags: <Sync> ... NLRI's for which peer can send multiple paths: inet-unicast ...
user@R4> show bgp neighbor 10.0.0.80 Peer: 10.0.0.80+55416 AS 1 Local: 10.0.0.40+179 AS 1 Type: Internal State: Established (route reflector client)Flags: <Sync> ,,, NLRI's for which peer can receive multiple paths: inet-unicast ...
user@R8> show bgp neighbor 10.0.0.40 Peer: 10.0.0.40+179 AS 1 Local: 10.0.0.80+55416 AS 1 Type: Internal State: Established Flags: <Sync> ... NLRI's for which peer can send multiple paths: inet-unicast ...
验证路由器 R1 是否正在播发多条路径
目的
确保将到 172.16.198.1/32 目标的多条路径和到 172.16.199.1/32 目标的多条路径播发到路由器 R4。
操作
user@R1> show route advertising-protocol bgp 10.0.0.40 inet.0: 21 destinations, 25 routes (21 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.0.0.50/32 10.0.15.2 100 2 2 I * 10.0.0.60/32 10.0.0.20 100 2 I * 10.0.0.70/32 10.0.0.30 100 2 I * 172.16.198.1/32 10.0.0.20 100 2 I 10.0.15.2 100 2 2 I * 172.16.199.1/32 10.0.0.20 100 2 I 10.0.0.30 100 2 I 10.0.15.2 100 2 2 I * 172.16.200.0/30 10.0.0.20 100 2 I
意义
当您看到一个前缀和多个下一跃点时,表示有多个路径播发到路由器 R4。
验证路由器 R4 是否正在接收并播发多条路径
目的
确保从路由器 R1 接收到 172.16.199.1/32 目标的多条路径,并将其播发到路由器 R8。确保从路由器 R1 接收到 172.16.198.1/32 目标的多条路径,但只有一条指向此目标的路径播发到路由器 R8。
操作
user@R4> show route receive-protocol bgp 10.0.0.10 inet.0: 19 destinations, 22 routes (19 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.0.0.50/32 10.0.15.2 100 2 2 I * 10.0.0.60/32 10.0.0.20 100 2 I * 10.0.0.70/32 10.0.0.30 100 2 I * 172.16.198.1/32 10.0.0.20 100 2 I 10.0.15.2 100 2 2 I * 172.16.199.1/32 10.0.0.20 100 2 I 10.0.0.30 100 2 I 10.0.15.2 100 2 2 I * 172.16.200.0/30 10.0.0.20 100 2 I
user@R4> show route advertising-protocol bgp 10.0.0.80 inet.0: 19 destinations, 22 routes (19 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.0.0.50/32 10.0.15.2 100 2 2 I * 10.0.0.60/32 10.0.0.20 100 2 I * 10.0.0.70/32 10.0.0.30 100 2 I * 172.16.198.1/32 10.0.0.20 100 2 I * 172.16.199.1/32 10.0.0.20 100 2 I 10.0.0.30 100 2 I 10.0.15.2 100 2 2 I * 172.16.200.0/30 10.0.0.20 100 2 I
意义
该 show route receive-protocol
命令显示路由器 R4 接收到 172.16.198.1/32 目标的两条路径和到 172.16.199.1/32 目标的三条路径。该 show route advertising-protocol
命令显示路由器 R4 仅播发一条路径到 172.16.198.1/32 目标,并将所有三条路径播发到 172.16.199.1/32 目标。
由于应用于路由器 R4 的前缀策略,路由器 R4 不会播发到 172.16.198.1/32 目标的多个路径。路由器 R4 仅播发到 172.16.198.1/32 目标的一条路径,即使它收到到此目标的多条路径也是如此。
验证路由器 R8 是否正在接收多个路径
目的
确保路由器 R8 通过路由器 R4 接收到 172.16.199.1/32 目标的多条路径。确保路由器 R8 仅通过路由器 R4 接收到 172.16.198.1/32 目标的一条路径。
操作
user@R8> show route receive-protocol bgp 10.0.0.40 inet.0: 18 destinations, 20 routes (18 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 10.0.0.50/32 10.0.15.2 100 2 2 I * 10.0.0.60/32 10.0.0.20 100 2 I * 10.0.0.70/32 10.0.0.30 100 2 I * 172.16.198.1/32 10.0.0.20 100 2 I * 172.16.199.1/32 10.0.0.20 100 2 I 10.0.0.30 100 2 I 10.0.15.2 100 2 2 I * 200.1.1.0/30 10.0.0.20 100 2 I
检查路径 ID
目的
在下游设备路由器 R4 和路由器 R8 上,验证路径 ID 是否唯一标识路径。查找 Addpath Path ID:
字符串。
操作
user@R4> show route 172.16.199.1/32 detail inet.0: 18 destinations, 20 routes (18 active, 0 holddown, 0 hidden) 172.16.199.1/32 (3 entries, 3 announced) *BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 9 Source: 10.0.0.10 Next hop type: Router, Next hop index: 676 Next hop: 10.0.14.1 via lt-1/2/0.41, selected Protocol next hop: 10.0.0.20 Indirect next hop: 92041c8 262146 State: <Active Int Ext> Local AS: 1 Peer AS: 1 Age: 1:44:37 Metric2: 2 Task: BGP_1.10.0.0.10+64227 Announcement bits (3): 2-KRT 3-BGP RT Background 4-Resolve tree 1 AS path: 2 I (Originator) Cluster list: 10.0.0.10 AS path: Originator ID: 10.0.0.20 Accepted Localpref: 100 Router ID: 10.0.0.10 Addpath Path ID: 1 BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 4 Source: 10.0.0.10 Next hop type: Router, Next hop index: 676 Next hop: 10.0.14.1 via lt-1/2/0.41, selected Protocol next hop: 10.0.0.30 Indirect next hop: 92042ac 262151 State: <NotBest Int Ext> Inactive reason: Not Best in its group - Router ID Local AS: 1 Peer AS: 1 Age: 1:44:37 Metric2: 2 Task: BGP_1.10.0.0.10+64227 Announcement bits (1): 3-BGP RT Background AS path: 2 I (Originator) Cluster list: 10.0.0.10 AS path: Originator ID: 10.0.0.30 Accepted Localpref: 100 Router ID: 10.0.0.10 Addpath Path ID: 2 BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 4 Source: 10.0.0.10 Next hop type: Router, Next hop index: 676 Next hop: 10.0.14.1 via lt-1/2/0.41, selected Protocol next hop: 10.0.15.2 Indirect next hop: 92040e4 262150 State: <Int Ext> Inactive reason: AS path Local AS: 1 Peer AS: 1 Age: 1:44:37 Metric2: 2 Task: BGP_1.10.0.0.10+64227 Announcement bits (1): 3-BGP RT Background AS path: 2 2 I Accepted Localpref: 100 Router ID: 10.0.0.10 Addpath Path ID: 3
user@R8> show route 172.16.199.1/32 detail inet.0: 17 destinations, 19 routes (17 active, 0 holddown, 0 hidden) 172.16.199.1/32 (3 entries, 1 announced) *BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 9 Source: 10.0.0.40 Next hop type: Router, Next hop index: 1045 Next hop: 10.0.48.1 via lt-1/2/0.84, selected Protocol next hop: 10.0.0.20 Indirect next hop: 91fc0e4 262148 State: <Active Int Ext> Local AS: 1 Peer AS: 1 Age: 1:56:51 Metric2: 3 Task: BGP_1.10.0.0.40+179 Announcement bits (2): 2-KRT 4-Resolve tree 1 AS path: 2 I (Originator) Cluster list: 10.0.0.40 10.0.0.10 AS path: Originator ID: 10.0.0.20 Accepted Localpref: 100 Router ID: 10.0.0.40 Addpath Path ID: 1 BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 4 Source: 10.0.0.40 Next hop type: Router, Next hop index: 1045 Next hop: 10.0.48.1 via lt-1/2/0.84, selected Protocol next hop: 10.0.0.30 Indirect next hop: 91fc1c8 262152 State: <NotBest Int Ext> Inactive reason: Not Best in its group - Router ID Local AS: 1 Peer AS: 1 Age: 1:56:51 Metric2: 3 Task: BGP_1.10.0.0.40+179 AS path: 2 I (Originator) Cluster list: 10.0.0.40 10.0.0.10 AS path: Originator ID: 10.0.0.30 Accepted Localpref: 100 Router ID: 10.0.0.40 Addpath Path ID: 2 BGP Preference: 170/-101 Next hop type: Indirect Next-hop reference count: 4 Source: 10.0.0.40 Next hop type: Router, Next hop index: 1045 Next hop: 10.0.48.1 via lt-1/2/0.84, selected Protocol next hop: 10.0.15.2 Indirect next hop: 91fc2ac 262153 State: <Int Ext> Inactive reason: AS path Local AS: 1 Peer AS: 1 Age: 1:56:51 Metric2: 3 Task: BGP_1.10.0.0.40+179 AS path: 2 2 I (Originator) Cluster list: 10.0.0.40 AS path: Originator ID: 10.0.0.10 Accepted Localpref: 100 Router ID: 10.0.0.40 Addpath Path ID: 3