本帖最后由 碧云天 于 2020-3-8 09:38 编辑 一.测试拓扑测试总结:1.在MA环境下,EBGP的路由下一跳会自动优
--上图中R3将从IBGP邻居学习到的路由传给EBGP邻居R4时,会自动优化下一跳地址为R1的MA网段地址
2.上图中R3指定IBGP邻居R4时,不用指定路由下一跳地址为自己,这样,R3把通过EBGP学习到的路由发送给R1时,就不会修改下一跳地址。
二.基本配置
1.R2路由器hostname R2
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface Loopback172
ip address 172.16.2.2 255.255.255.0
interface FastEthernet1/0
ip address 12.1.1.2 255.255.255.0
no shutdown
2.R1路由器hostname R1
interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Loopback172
ip address 172.16.1.1 255.255.255.0
interface FastEthernet0/0
ip address 134.1.1.1 255.255.255.0
no shutdown
interface FastEthernet1/0
ip address 12.1.1.1 255.255.255.0
no shutdown
router rip
version 2
network 1.0.0.0
network 134.1.0.0
no auto-summary
3.R3路由器hostname R3
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Loopback172
ip address 172.16.3.3 255.255.255.0
interface FastEthernet0/0
ip address 134.1.1.3 255.255.255.0
no shutdown
router rip
version 2
network 3.0.0.0
network 134.1.0.0
no auto-summary
4.R4路由器hostname R4
interface Loopback0
ip address 4.4.4.4 255.255.255.0
interface Loopback172
ip address 172.16.4.4 255.255.255.0
interface FastEthernet0/0
ip address 134.1.1.4 255.255.255.0
no shutdown
三.BGP配置
1.R2路由器hostname R2
router bgp 65002
bgp router-id 2.2.2.2
network 172.16.2.0 mask 255.255.255.0
neighbor 12.1.1.1 remote-as 65001
2.R1路由器router bgp 65001
bgp router-id 1.1.1.1
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 update-source Loopback0
neighbor 12.1.1.2 remote-as 65002
3.R3路由器router bgp 65001
bgp router-id 3.3.3.3
neighbor 1.1.1.1 remote-as 65001
neighbor 1.1.1.1 update-source Loopback0
neighbor 134.1.1.4 remote-as 65004
4.R4路由器router bgp 65004
bgp router-id 4.4.4.4
neighbor 134.1.1.3 remote-as 65001
四.下一跳地址验证1.R2宣告本地路由到bgp进程,本地显示的下一跳地址为0.0.0.0R2#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 172.16.2.0/24 0.0.0.0 0 32768 i
R2#
2.R1通过EBGP学习到的BGP路由,下一跳地址为对等体的更新源地址R1#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 172.16.2.0/24 12.1.1.2 0 0 65002 i
R1#
3.R3通过IBGP学习到的BGP路由,默认下一跳地址不会被修改R3#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
* i 172.16.2.0/24 12.1.1.2 0 100 0 65002 i
R3#
备注:没有>,因为R3没有到12.1.1.2的路由,这时R4无法通过R3学习到该路由。4.R1修改对R3的BGP邻居的下一跳地址为自己R1(config)#router bgp 65001
R1(config-router)# neighbor 3.3.3.3 next-hop-self
5.此时R3通过IBGP学习到的BGP路由,下一跳地址已经修改R3#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*>i 172.16.2.0/24 1.1.1.1 0 100 0 65002 i
R3#
备注:这次有>,因为R3通过RIP学习到1.1.1.1的路由6.R4通过EBGP邻居R3学习到的BGP路由下一跳地址并不是R3的接口地址R4#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 172.16.2.0/24 134.1.1.1 0 65001 65002 i
R4#
备注:因为R3检测到到1.1.1.1是通过134.1.1.1,而134.1.1.4与它相同网段,所以告知R4下一跳地址为134.1.1.1,从debug日志可以看得出来。R3#show ip route rip | in FastEthernet
R 1.1.1.0 [120/1] via 134.1.1.1, 00:00:15, FastEthernet0/0
R3#
R3#debug ip bgp updates
BGP updates debugging is on for address family: IPv4 Unicast
R3#clear ip bgp * soft
R3#
*Mar 6 13:11:40.051: BGP(0): 134.1.1.4 NEXT_HOP is set to 134.1.1.1 by first hop lookup for net 172.16.2.0/24
*Mar 6 13:11:40.051: BGP(0): (base) 134.1.1.4 send UPDATE (format) 172.16.2.0/24, next 134.1.1.1, metric 0, path 65002
7.R4宣告本地路由到BGP进程R4(config)#router bgp 65004
R4(config-router)#network 172.16.4.0 mask 255.255.255.0
8.R3通过EBGP邻居学习到该条路由下一跳地址为R4的接口地址R3#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*>i 172.16.2.0/24 1.1.1.1 0 100 0 65002 i
*> 172.16.4.0/24 134.1.1.4 0 0 65004 i
R3#
9.R1学习到的该路由下一跳地址仍然为R4的地址R1#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 172.16.2.0/24 12.1.1.2 0 0 65002 i
*>i 172.16.4.0/24 134.1.1.4 0 100 0 65004 i
R1#
备注:因为R3指定R1的邻居的时候,没有设定下一跳地址为自己。9.R2通过EBGP邻居学习到下一跳地址已经被修改R2#show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 172.16.2.0/24 0.0.0.0 0 32768 i
*> 172.16.4.0/24 12.1.1.1 0 65001 65004 i
R2#