CCNP精粹系列之三十二--BGP下一跳问题,推荐
Bgp的下一跳
R1:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
R1(config)#int lo0
R1(config-if)#ip addr 192.168.10.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router bgp 64500
fig-router)#neighbor 202.110.100.2 remote-as 64500
R1(config-router)#net 202.110.100.0
R1(config-router)#net 192.168.10.0
R1(config-router)#exit
R2上:
Router(config)#host R2
R2(config)#int s1/0
R2(config-if)#ip addr 202.110.100.2 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#int s1/1
R2(config-if)#ip addr 202.110.101.1 255.255.255.0
R2(config-if)#encap hdlc
R2(config-if)#clock rate 56000
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router bgp 64500
R2(config-router)#neighbor 202.110.100.1 remote-as 64500
R2(config-router)#neighbor 202.110.101.2 remote-as 64501
R2(config-router)#net 202.110.100.0
R2(config-router)#net 202.110.101.0
R3上:
R3(config-if)#int fa0/0
R3(config-if)#ip addr 192.168.20.1 255.255.255.0
R3(config-if)#no shut
R3(config)#int s1/1
R3(config-if)#ip addr 202.110.101.2 255.255.255.0
R3(config-if)#encap hdlc
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#router bgp 64501
R3(config-router)#neighbor 202.110.101.1 remote-as 64500
R3(config-router)#net 202.110.101.0
R3(config-router)#net 192.168.20.0
在R1上测试:
R1#show ip bgp
BGP table version is 7, local router ID is 202.110.100.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
*> 192.168.10.0 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />0.0.0.0 0 32768 i
*>i192.168.20.0 202.110.101.2 0 100 0 64501 i
* i202.110.100.0 202.110.100.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i202.110.101.0 202.110.100.2 0 100 0 i
R1#
我们在R1上查看fa0/0的路由下一跳不是常规下我们设想的100.2,而是101.2 ,
总结:路由器ebgp邻居处收到路由后,再把该路由转发给自己的IBGP邻居时,保留了路由的下一跳。
解决办法:
通告路由器转发“EBGP邻居的路由”给IBGP邻居时,修改路由的下一跳为自己的端口的下一跳ip。
语法格式:
(config-router)#neighbor 邻居ip next-hop-self
注意;这里邻居IP是指IBGP(内部路由器)。本试验中的R1,如果将这个ip写成EBGP,本试验的202.110.101.2,那么试验结果是错误的,至于错误结果就不做了,所以朋友们一定要注意。
所以在R2上做如下修改:
R2(config)#router bgp 64500
R2(config-router)#neighbor 202.110.101.2 remote-as 64501
R2(config-router)#neighbor 202.110.100.1 next-hop-self
R2(config-router)#exit
再次在R1上看效果:
R1#show ip bgp
BGP table version is 9, local router ID is 202.110.100.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
*> 192.168.10.0 0.0.0.0 0 32768 i
*>i192.168.20.0 202.110.100.2 0 100 0 64501 i
* i202.110.100.0 202.110.100.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*>i202.110.101.0 202.110.100.2 0 100 0 i
显然可以看出R1学习到的R3路由192.168.20.0的下一跳变为202.110.100.2 ,所以我们的修改下一跳成功。一切和理论符合。
BGP的med属性:
目睹实战现场:
转载于:https://blog.51cto.com/shenleigang/152633