要求:
1.R1、R2、R3建立IBGP对等体AS号为65001。R1、R3、R4建立
EBGP对等体,R4对等体号为65002。
2.IBGP使用环回口建立邻居,EBGP使用直连接口建立邻居
3.R2的192.168.2.1网段去往R4的192.168.1.1网段下一跳需要为R1
1.基础配置:
R1 ip地址配置
int g0/0
no swi
ip a 12.0.0.1 24
int g0/1
no swi
ip a 14.0.0.1 24
int l 0
ip a 1.1.1.1 32
R2 ip地址配置
int g0/0
no swi
ip a 12.0.0.2 24
int g0/1
no swi
ip a 23.0.0.1 24
int l 0
ip a 2.2.2.2 32
R3 ip地址配置
int g0/1
no swi
ip a 23.0.0.2 24
int g0/2
no swi
ip a 34.0.0.1 24
int l 0
ip a 3.3.3.3 32
R4 ip地址配置
int g0/1
no swi
ip a 14.0.0.2 24
int g0/2
no swi
ip a 34.0.0.2 24
int l 0
ip a 4.4.4.4 32
int l 1
ip a 192.168.1.1 24
2.使用ospf使得IBGP对等体环回口可达
R1 ospf配置
router ospf 1
graceful-restart
network 1.1.1.1 0.0.0.0 area 0
network 12.0.0.0 0.0.0.3 area 0
R2 ospf配置
router ospf 1
graceful-restart
network 2.2.2.2 0.0.0.0 area 0
network 12.0.0.0 0.0.0.3 area 0
network 23.0.0.0 0.0.0.3 area 0
R2 ospf配置
router ospf 1
graceful-restart
network 3.3.3.3 0.0.0.0 area 0
network 23.0.0.0 0.0.0.3 area 0
以R1测试ping通R2、R3环回口可达
3.BGP配置
R1
router bgp 65001
neighbor 2.2.2.2 remote-as 65001
neighbor 2.2.2.2 update-source Loopback 0
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 update-source Loopback 0
neighbor 14.0.0.2 remote-as 65002
R2
router bgp 65001
neighbor 1.1.1.1 remote-as 65001
neighbor 1.1.1.1 update-source Loopback 0
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 update-source Loopback 0
network 192.168.2.0 mask 255.255.255.0
R3
router bgp 65001
neighbor 1.1.1.1 remote-as 65001
neighbor 1.1.1.1 update-source Loopback 0
neighbor 2.2.2.2 remote-as 65001
neighbor 2.2.2.2 update-source Loopback 0
neighbor 34.0.0.2 remote-as 65002
R4
route bgp 65002
neighbor 14.0.0.1 remote-as 65001
neighbor 34.0.0.1 remote-as 65001
network 192.168.1.0 mask 255.255.255.0
此时因为IBGP特性,从EBGP学到的路由传递给IBGP时,不会修改下一跳属性,所以在R2上查看路由可以发现下一跳为R4的接口,此时是不能通信的
需要在R1上的BGP中新增一条命令
neighbor 2.2.2.2 next-hop-self #修改下一跳属性为自己
此时在R2上可以发现,下一跳为1.1.1.1,别*>表示有效最佳状态
此时完成了R2去往R4下一跳为R1