7、为什么学不到不是直连的EBGP路由?分析其原因是由IBGP邻居学来的信息产生如下结果:
A
:如果在R2
à
R4
上同步关闭,则会将IBGP信息传递给EBGP邻居 (12.3以上IOS版本的路由器默认为同步关闭状态)
B
:如果在R2
à
R4
上同步开启,则不会将IBGP信息传递给EBGP邻居。原因为:BGP要求,从IBGP邻居学来的路由信息理应不传递给EBGP邻居,因为直接从IBGP邻居学来的路由信息并不一定是可达的路由。那么我们看一下R2的BGP表,看有没有这条路由存在:
R2#sh ip bgp
BGP table version is 10, local router ID is 192.16.255.5
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
* 10.1.255.0/30 10.1.255.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
*> 10.1.255.4/30 0.0.0.0 0 32768 i
* i 10.1.255.6 0 100 0 i
r i10.1.255.8/30 10.1.255.10 0 100 0 i
r>i 10.1.255.6 0 100 0 i
r>i10.1.255.12/30 10.1.255.10 0 100 0 i
*> 130.130.1.0/24 10.1.255.1 0 0 64512 i
* i150.150.1.0/24 10.1.255.14 0 100 0 64514 i(发现BGP中存在这条路由,
但没有被选为选中最佳)
|
8
、再看一下150.150.1.0/24
R2#sh ip bgp 150.150.1.0
BGP routing table entry for 150.150.1.0/24, version 0
Paths: (1 available, no best path)
Not advertised to any peer
64514
10.1.255.14 (metric 192) from 10.1.255.10 (10.1.255.13)
Origin IGP, metric 0, localpref 100, valid, internal, not synchronized (没同步起来)
|
三、用上述命令一步一步排错是最好不过了。根据BGP同步规则,开启同步的话,边缘路由器不使用或不通告给任何EBGP邻居从IBGP邻居学习到的路由,在运行了其它系统,并且同步是开启状态。通过重分发让IGP中也学习到EGP的路由,图中可以是在R2和R4当中使用重分发bgp的路由到ospf 当中,让R2和R4学到EBGP的路由,EBGP也能学到IBGP的路由:
R2(config)#router ospf 1
R2(config-router)#redistribute bgp 64513 metric 200 subnets
R4(config)#router ospf 1
R4(config-router)#redistribute bgp 64513 metric 200 subnets
|
2
、现在再看一下R1和R4:
R1#sh ip route
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, su - IS-IS summary, 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
10.0.0.0/30 is subnetted, 4 subnets
B 10.1.255.4 [20/0] via 10.1.255.2, 00:10:16
C 10.1.255.0 is directly connected, Serial1/1
B 10.1.255.12 [20/0] via 10.1.255.2, 00:10:47
B 10.1.255.8 [20/0] via 10.1.255.2, 00:10:47
130.130.0.0/24 is subnetted, 1 subnets
C 130.130.1.0 is directly connected, Loopback0
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 10.1.255.2, 00:01:07
R4#sh ip route
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, su - IS-IS summary, 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
10.0.0.0/30 is subnetted, 4 subnets
O 10.1.255.4 [110/128] via 10.1.255.9, 00:01:21, Serial1/0
O 10.1.255.0 [110/192] via 10.1.255.9, 00:01:21, Serial1/0
C 10.1.255.12 is directly connected, Serial1/1
C 10.1.255.8 is directly connected, Serial1/0
130.130.0.0/24 is subnetted, 1 subnets
O E2 130.130.1.0 [110/200] via 10.1.255.9, 00:01:21, Serial1/0 (会以2类的OE 来显示了)
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 10.1.255.14, 00:12:37
|
3
、现在能学到了,我们再来到R2上看一下和150.150.1.0/30的同步关系:
R2#sh ip bgp 150.150.1.0
BGP routing table entry for 150.150.1.0/24, version 16
Paths: (1 available, best #1, table Default-IP-Routing-Table, RIB-failure(17))
Advertised to update-groups:
1
64514
10.1.255.14 (metric 192) from 10.1.255.10 (10.1.255.13)
Origin IGP, metric 0, localpref 100, valid, internal, synchronized, best (现在同步了)
|
4
、由于在上图显示R4学到130.130.1.0/24以 0E2来显示,所以说会造成R5学不到130.130.1.0这条路由。因为在R4上就不存在这条路由。补充一下重要的事情:请把R2当时设置的BGP router-id no 掉。让R4学到130.130.1.0/24并以bgp最佳形式存在,因为根据
BGP
同步规则:需要IBGP也学习到相同路由,不然不通告给任何EBGP邻居从IBGP邻居学习到路由:
R2(config)#router bgp 64513
R2(config-router)#no router-id 172.16.255.5 (no 掉之前在R2上指高的router-id)
|
5、保证在R4上存在最佳路径的BGP。如以这样显示:(r>i)
R4#sh ip bgp
…………
Network Next Hop Metric LocPrf Weight Path
r>i10.1.255.0/30 10.1.255.5 0 100 0 i
r>i10.1.255.4/30 10.1.255.9 0 100 0 i
r i 10.1.255.5 0 100 0 i
* i10.1.255.8/30 10.1.255.9 0 100 0 i
*> 0.0.0.0 0 32768 i
* 10.1.255.12/30 10.1.255.14 0 0 64514 i
*> 0.0.0.0 0 32768 i
r>i130.130.1.0/24 10.1.255.1 0 100 0 64512 i
*> 150.150.1.0/24 10.1.255.14 0 0 64514 i
|
6、现在R5上也正常了:
R5#sh ip route
………………
Gateway of last resort is not set
10.0.0.0/30 is subnetted, 4 subnets
B 10.1.255.4 [20/0] via 10.1.255.13, 00:07:17
B 10.1.255.0 [20/0] via 10.1.255.13, 00:07:17
C 10.1.255.12 is directly connected, Serial1/0
B 10.1.255.8 [20/0] via 10.1.255.13, 00:07:17
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [20/0] via 10.1.255.13, 00:07:47
150.150.0.0/24 is subnetted, 1 subnets
C 150.150.1.0 is directly connected, Loopback0
|
四、总结:在BGP当中,IBGP的路由器关闭同步则会将IBGP信息传递给EBGP邻居,如果开启同步,则不会将IBGP信息传递给EBGP邻居。原因是BGP要求,从IBGP邻居学来的路由信息理应不传递给EBGP邻居,因为直接从IBGP邻居学来的路由信息并不一定是可达的路由。如果开启同步并运行了不同系统。可以在边缘路由器上用重分发把EGP发布到IGP当中,直到IGP中也学习到EGP路由。这样所有的BGP路由都能学到。