使用eNSP搭建实验环境:
1)确保设备之间的连通性
2)配置BGP
3)配置RR
实现此案例需要按照如下步骤进行。
//R1的基本配置
interface gi0/0/0
ip address 192.168.12.1 255.255.255.0
interface gi0/0/1
ip address 192.168.1.254 255.255.255.0
interface loopback 13
ip address 10.10.1.1 255.255.255.0
ospf 1 router-id 1.1.1.1
area 0
network 192.168.12.0 0.0.0.255
network 10.10.1.1 0.0.0.0
//R2的基本配置
interface gi0/0/1
ip address 192.168.12.2 255.255.255.0
interface gi0/0/0
ip address 192.168.23.2 255.255.255.0
interface loopback 0
ip address 10.10.2.2 255.255.255.0
ospf 1 router-id 2.2.2.2
area 0
network 192.168.12.2 0.0.0.0
network 192.168.23.2 0.0.0.0
network 10.10.2.2 0.0.0.0
//R3的基本配置
interface gi0/0/1
ip address 192.168.23.3 255.255.255.0
interface gi0/0/2
ip address 192.168.2.254 255.255.255.0
interface loopback 13
ip address 10.10.3.3 255.255.255.0
ospf 1 router-id 3.3.3.3
area 0
network 192.168.23.3 0.0.0.0
network 10.10.3.3 0.0.0.0
//R1的配置
bgp 64512
router-id 1.1.1.1
peer 10.10.2.2 as-number 64512
peer 10.10.2.2 connect-interface loopback 13
import-route direct
//R2的配置
bgp 64512
router-id 2.2.2.2
peer 10.10.1.1 as-number 64512
peer 10.10.1.1 connect-interface loopback 0
peer 10.10.3.3 as-number 64512
peer 10.10.3.3 connect-interface loopback 0
//R3的配置
bgp 64512
router-id 3.3.3.3
peer 10.10.2.2 as-number 64512
peer 10.10.2.2 connect-interface loopback 13
network 192.168.2.0 255.255.255.0
//查看R1的路由表
<Huawei>dis bgp ro
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 8
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.10.1.0/24 0.0.0.0 0 0 ?
*> 10.10.1.1/32 0.0.0.0 0 0 ?
*> 127.0.0.0 0.0.0.0 0 0 ?
*> 127.0.0.1/32 0.0.0.0 0 0 ?
*> 192.168.1.0 0.0.0.0 0 0 ?
*> 192.168.1.254/32 0.0.0.0 0 0 ?
*> 192.168.12.0 0.0.0.0 0 0 ?
*> 192.168.12.1/32 0.0.0.0 0 0 ?
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 16 Routes : 16
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.0/24 Direct 0 0 D 10.10.1.1 LoopBack13
10.10.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.2.2/32 OSPF 10 1 D 192.168.12.2 GigabitEthernet
0/0/0
10.10.3.3/32 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/1
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.12.0/24 Direct 0 0 D 192.168.12.1 GigabitEthernet
0/0/0
192.168.12.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.23.0/24 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
//查看R2的路由表
<Huawei>dis bgp ro
BGP Local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.10.1.0/24 10.10.1.1 0 100 0 ?
*>i 192.168.1.0 10.10.1.1 0 100 0 ?
*>i 192.168.2.0 10.10.3.3 0 100 0 i
*>i 192.168.12.0 10.10.1.1 0 100 0 ?
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
10.10.1.1/32 OSPF 10 1 D 192.168.12.1 GigabitEthernet
0/0/1
10.10.2.0/24 Direct 0 0 D 10.10.2.2 LoopBack0
10.10.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.10.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.10.3.3/32 OSPF 10 1 D 192.168.23.3 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
192.168.2.0/24 IBGP 255 0 RD 10.10.3.3 GigabitEthernet
0/0/0
192.168.12.0/24 Direct 0 0 D 192.168.12.2 GigabitEthernet
0/0/1
192.168.12.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.23.0/24 Direct 0 0 D 192.168.23.2 GigabitEthernet
0/0/0
192.168.23.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
//查看R3的路由表
<Huawei>dis bgp ro
BGP Local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 192.168.2.0 0.0.0.0 0 0 i
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 16 Routes : 16
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.1/32 OSPF 10 2 D 192.168.23.2 GigabitEthernet
0/0/1
10.10.2.2/32 OSPF 10 1 D 192.168.23.2 GigabitEthernet
0/0/1
10.10.3.0/24 Direct 0 0 D 10.10.3.3 LoopBack13
10.10.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.3.255/32 Direct 0 0 D 127.0.0.1 LoopBack13
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.2.0/24 Direct 0 0 D 192.168.2.254 GigabitEthernet
0/0/2
192.168.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.12.0/24 OSPF 10 2 D 192.168.23.2 GigabitEthernet
0/0/1
192.168.23.0/24 Direct 0 0 D 192.168.23.3 GigabitEthernet
0/0/1
192.168.23.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
可以看到,由于IBGP 遵守水平分割规则,R2不能将学习到的路由互相转发,造成R1与R3不能学习到对方的路由。
PC1与PC2不能ping通。
//R2的配置
bgp 64512
//将10.10.1.1配置成了路由反射器客户端,同时自己成为了路由反射器
peer 10.10.1.1 reflect-client
//将10.10.3.3配置成了路由反射器客户端
peer 10.10.3.3 reflect-client
//查看R1的路由表
<Huawei>dis bgp ro
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 9
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.10.1.0/24 0.0.0.0 0 0 ?
*> 10.10.1.1/32 0.0.0.0 0 0 ?
*> 127.0.0.0 0.0.0.0 0 0 ?
*> 127.0.0.1/32 0.0.0.0 0 0 ?
*> 192.168.1.0 0.0.0.0 0 0 ?
*> 192.168.1.254/32 0.0.0.0 0 0 ?
*>i 192.168.2.0 10.10.3.3 0 100 0 i
*> 192.168.12.0 0.0.0.0 0 0 ?
*> 192.168.12.1/32 0.0.0.0 0 0 ?
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 17 Routes : 17
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.0/24 Direct 0 0 D 10.10.1.1 LoopBack13
10.10.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.2.2/32 OSPF 10 1 D 192.168.12.2 GigabitEthernet
0/0/0
10.10.3.3/32 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
0/0/1
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.0/24 IBGP 255 0 RD 10.10.3.3 GigabitEthernet
0/0/0
192.168.12.0/24 Direct 0 0 D 192.168.12.1 GigabitEthernet
0/0/0
192.168.12.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.23.0/24 OSPF 10 2 D 192.168.12.2 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
//查看R2的路由表
<Huawei>dis bgp ro
BGP Local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.10.1.0/24 10.10.1.1 0 100 0 ?
*>i 192.168.1.0 10.10.1.1 0 100 0 ?
*>i 192.168.2.0 10.10.3.3 0 100 0 i
*>i 192.168.12.0 10.10.1.1 0 100 0 ?
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
10.10.1.1/32 OSPF 10 1 D 192.168.12.1 GigabitEthernet
0/0/1
10.10.2.0/24 Direct 0 0 D 10.10.2.2 LoopBack0
10.10.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.10.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.10.3.3/32 OSPF 10 1 D 192.168.23.3 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
192.168.2.0/24 IBGP 255 0 RD 10.10.3.3 GigabitEthernet
0/0/0
192.168.12.0/24 Direct 0 0 D 192.168.12.2 GigabitEthernet
0/0/1
192.168.12.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.12.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.23.0/24 Direct 0 0 D 192.168.23.2 GigabitEthernet
0/0/0
192.168.23.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
//查看R3的路由表
<Huawei>dis bgp ro
BGP Local router ID is 3.3.3.3
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.10.1.0/24 10.10.1.1 0 100 0 ?
*>i 192.168.1.0 10.10.1.1 0 100 0 ?
*> 192.168.2.0 0.0.0.0 0 0 i
*>i 192.168.12.0 10.10.1.1 0 100 0 ?
<Huawei>dis ip ro
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.10.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
10.10.1.1/32 OSPF 10 2 D 192.168.23.2 GigabitEthernet
0/0/1
10.10.2.2/32 OSPF 10 1 D 192.168.23.2 GigabitEthernet
0/0/1
10.10.3.0/24 Direct 0 0 D 10.10.3.3 LoopBack13
10.10.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack13
10.10.3.255/32 Direct 0 0 D 127.0.0.1 LoopBack13
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 IBGP 255 0 RD 10.10.1.1 GigabitEthernet
0/0/1
192.168.2.0/24 Direct 0 0 D 192.168.2.254 GigabitEthernet
0/0/2
192.168.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2
192.168.12.0/24 OSPF 10 2 D 192.168.23.2 GigabitEthernet
0/0/1
192.168.23.0/24 Direct 0 0 D 192.168.23.3 GigabitEthernet
0/0/1
192.168.23.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
可以看到,路由反射器将从客户处学到的路由转发给除此客户外的所有的客户,R1与R3可以学习到对方的路由。
PC1与PC2可以ping通。