实验14 IBPG与EBGP路由决策1
——Router-id与邻居ip地址对路由决策的影响
一、
实验拓扑图,如图1.1所示:
图1.1 IBGP与EBGP实验2拓扑图
二、
预配置: Router>en
Router#conf t
Router(config)#no ip do lo Router(config)#line 0
Router(config-line)#no exec-t Router(config-line)#logg s Router(config-line)#ho R1
R1(config)#int s0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0 R1(config)#int s0/1
R1(config-if)#ip add 14.0.0.1 255.255.255.0 R1(config-if)#no sh
R1(config-if)#int lo0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#router bgp 100 //起bgp进程
R1(config-router)#neighbor 12.0.0.2 remote-as 100 //建立bgp邻居
R1(config-router)#network 1.1.1.0 mask 255.255.255.0 //宣告1.1.1.0/24网络 2. R2的预配置:
Router>en
Router#conf t
Router(config)#no ip do lo Router(config)#line 0
Router(config-line)#no exec-t 1. R1的预配置:
Router(config-line)#logg s
Router(config-line)#ho R2 R2(config)#int s0/0
R2(config-if)#ip add 12.0.0.2 255.255.255.0 R2(config-if)#no sh
R2(config-router)#int s0/1
R2(config-if)#ip add 23.0.0.2 255.255.255.0 R2(config-if)#no sh R2(config-if)#int lo0
R2(config-if)#ip add 2.2.2.2 255.255.255.0 R2(config-if)#router bgp 100
R2(config-router)#nei 12.0.0.1 remote-as 100
R2(config-router)#neighbor 12.0.0.1 next-hop-self //设定下一跳自己,保证可达性 R2(config-router)#neighbor 23.0.0.3 remote-as 200
R2(config-router)#network 2.2.2.0 mask 255.255.255.0 //宣告2.2.2.0/24网络 3. R3的预配置:
Router>en Router#conf t
Router(config)#no ip do lo Router(config)#line 0
Router(config-line)#no exec-t
Router(config-line)#logg s Router(config-line)#ho R3 R3(config)#int s0/1
R3(config-if)#ip add 23.0.0.3 255.255.255.0 R3(config)#int s0/0
R3(config-if)#ip add 34.0.0.3 255.255.255.0 R3(config-if)#no sh R3(config-if)#int lo0
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-router)#ip route 12.0.0.0 255.255.255.0 23.0.0.2 R3(config)#router bgp 200
R3(config-router)#neighbor 23.0.0.2 remote-as 100 R3(config-router)#network 3.3.3.0 mask 255.255.255.0 4. R4的预配置
Router>en
Router#conf t
Router(config)#no ip do lo Router(config)#line 0 Router(config-line)#no exec-t Router(config-line)#logg s
Router(config-line)#ho R4 R4(config)#int s0/1
R4(config-if)#ip add 14.0.0.4 255.255.255.0
R4(config)#int s0/0
R4(config-if)#ip add 34.0.0.4 255.255.255.0 R4(config-if)#no sh R4(config-if)#int lo0
R4(config-if)#ip add 4.4.4.4 255.255.255.0 R4(config-if)#router bgp 100
R4(config-router)#neighbor 14.0.0.1 remote-as 100 R4(config-router)#neighbor 14.0.0.1 next-hop-self R4(config-router)#neighbor 34.0.0.3 remote-as 200 R4(config-router)#net 4.4.4.0 ma 255.255.255.0 5. 在R1上查看bgp表和路由表:
//查看R1上的bgp表
R1(config-router)#do sh ip bgp
BGP table version is 5, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 0.0.0.0 0 32768 i *>i2.2.2.0/24 12.0.0.2 0 100 0 i
* i3.3.3.0/24 14.0.0.4 0 100 0 200 i *>i 12.0.0.2 0 100 0 200 i *>i4.4.4.0/24 14.0.0.4 0 100 0 i
以上输出表明R1已经通过bgp学习到了通往R3两条路径,且优选R2到达R3。 //查看R1上的路由表
R1(config-router)#do sh ip rout
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 12.0.0.2, 00:14:31 3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 12.0.0.2, 03:48:49 4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [200/0] via 14.0.0.4, 00:14:06 12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial0/0 14.0.0.0/24 is subnetted, 1 subnets
C 14.0.0.0 is directly connected, Serial0/1
路由表里面存储了到达3.3.3.0/24的最优路径,通过R2到达。
因为默认的时候bgp router-id使用回环口的地址,R2的bgp router-id更小,所以优选R2转发数据。
6. 将R2的bgp router-id更改为4.4.4.4,将R4的bgp router-id更改为2.2.2.2,查看R1
上的BGP表:
R2(config-router)#bgp router-id 4.4.4.4 //修改R2的router-id为4.4.4.4 R4(config-router)#bgp router-id 2.2.2.2 //修改R4的router-id为2.2.2.2 //查看R1上的bgp表和路由表
R1#sh ip bgp
BGP table version is 20, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 0.0.0.0 0 32768 i *>i2.2.2.0/24 12.0.0.2 0 100 0 i *>i3.3.3.0/24 14.0.0.4 0 100 0 200 i * i 12.0.0.2 0 100 0 200 i *>i4.4.4.0/24 14.0.0.4 0 100 0 i R1#sh ip rout
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 12.0.0.2, 00:08:38 3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 14.0.0.4, 00:06:09 4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [200/0] via 14.0.0.4, 00:06:14 12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial0/0
14.0.0.0/24 is subnetted, 1 subnets
C 14.0.0.0 is directly connected, Serial0/1 以上输出验证了优选bgp router-id小的邻居转发数据,此事R4的bgp router-id 为2.2.2.2小于R2的bgp router-id 4.4.4.4,所以优选R4。
7. 将R2与R4的bgp router-id设为相同的值,再查看R1的路由表:
//将R2的bgp router-id设为2.2.2.2
R1#sh ip bgp
BGP table version is 27, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 0.0.0.0 0 32768 i *>i2.2.2.0/24 12.0.0.2 0 100 0 i *>i3.3.3.0/24 12.0.0.2 0 100 0 200 i * i 14.0.0.4 0 100 0 200 i *>i4.4.4.0/24 14.0.0.4 0 100 0 i R1#sh ip rout
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets
B 2.2.2.0 [200/0] via 12.0.0.2, 00:01:16 3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [200/0] via 12.0.0.2, 00:01:15 4.0.0.0/24 is subnetted, 1 subnets B 4.4.4.0 [200/0] via 14.0.0.4, 01:25:39 12.0.0.0/24 is subnetted, 1 subnets C 12.0.0.0 is directly connected, Serial0/0 14.0.0.0/24 is subnetted, 1 subnets
C 14.0.0.0 is directly connected, Serial0/1 此时,从R1到达R3的路径已经从途经R4更新为经R2到达,也就是说,当bgp router-id等因素相同时,优选邻居ip地址小的邻居路径到达目的地。