WWW.XUEXIZU.COM
2、Local_Perf(未设置) 3、Next_Hop(无)
4、AS_Path(同为1跳) 5、Origin起源(无) 6、MED值(未设置)
7、eBGP>iBGP(R3和R4同为R5的iBGP对等体) 8、cost(用于iBGP)
由于整网起OSPF协议,R1与R4之间是用以太网线路连接,因此R5通过R4到R1的cost值为65;而通过R3到R1的cost值为128,所以最终选择R4传来的下一跳为10.1.1.1的路由条目做为最佳路由装进路由表。
(注意:因为这里没有在R4上配置next-hop-self参数,所以R4在传递路由时遵循路由传递原则,即从eBGP对等体学来的路由,传递给自身直连的iBGP对等体,下一跳不改。)
以上我们分析了R1—R5的BGP表,了解到了部分BGP选路原则在网络中是如何工作的,下面我们将配置和调试BGP选路原则种的Weight属性、Local_Pref属性、AS_Path属性及MED属性。
Weight属性的用法和配置方法
基本配置不变,我们到R1上show ip bgp查看一下BGP路由表:
R1#show ip bgp
BGP table version is 12, 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
* 2.2.2.0/24 10.1.1.4 0 345 2 i * 13.1.1.3 0 345 2 i *> 12.1.1.2 0 0 2 i * 3.3.3.0/24 10.1.1.4 0 345 i *> 13.1.1.3 0 0 345 i * 12.1.1.2 0 2 345 i * 4.4.4.0/24 10.1.1.4 0 0 345 i *> 13.1.1.3 0 345 i * 12.1.1.2 0 2 345 i * 5.5.5.0/24 12.1.1.2 0 2 345 i * 13.1.1.3 0 345 i *> 10.1.1.4 0 345 i
天津汤姆一通互联网技术训练中心
WWW.XUEXIZU.COM
2.2.2.0的路由是从12.1.1.2学到的,也就是从R2学到的,默认的Weight值为0,因为这条路由不是由自己产生的(如果是自己产生的路由,默认为32768,到R2上show ip bgp看到的就会是32768)。下面我们在R1上修改BGP的Weight属性,使从R4传来的下一跳为10.1.1.4的路由为最优路由。
实验配置:
R1(config)#access-list 10 permit 2.2.2.0 0.0.0.255 //创建ACL匹配感兴趣的路由
R1(config)#route-map wei_2 permit 10 //配置策略路由wei_2,序号为10,允许通过 R1(config-route-map)#match ip address 10 //匹配ACL 10定义的路由 R1(config-route-map)#set weight 65535 //设置Weight的值为65535 R1(config-route-map)#exit R1(config)#router bgp 1
R1(config-router)#neighbor 10.1.1.4 route-map wei_2 in //在邻居10.1.1.4上应用策略路由 R1(config-router)#exit
上面的配置很关键,首先需要定义ACL,用来标记需要使用策略的路由,然后配置策略路由,匹配刚才定义的感兴趣的路由,最后分别应用到邻居上,注意方向为in(Weight属性本地有效),BGP会优先选择Weight值大的路径。
这样配置完成后,我们先在R1上clear ip bgp *,然后再来看看R1的BGP表:
R1#show ip bgp
BGP table version is 9, 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
* 2.2.2.0/24 13.1.1.3 0 345 2 i * 12.1.1.2 0 0 2 i *> 10.1.1.4 65535 345 2 i *> 3.3.3.0/24 13.1.1.3 0 0 345 i * 12.1.1.2 0 2 345 i *> 4.4.4.0/24 13.1.1.3 0 345 i * 12.1.1.2 0 2 345 i *> 5.5.5.0/24 13.1.1.3 0 345 i * 12.1.1.2 0 2 345 i
可以看到,不仅原来默认的Weight属性值发生了变化,并且也改变了2.2.2.0这个路由的下一跳为10.1.1.4,也就是R4了,成功地实现了用Weight属性来修改BGP的选路。再来看一下R1的路由表:
R1#show ip route bgp
2.0.0.0/24 is subnetted, 1 subnets
天津汤姆一通互联网技术训练中心
WWW.XUEXIZU.COM
B 2.2.2.0 [20/0] via 10.1.1.4, 00:34:34 3.0.0.0/24 is subnetted, 1 subnets
B 3.3.3.0 [20/0] via 13.1.1.3, 00:34:34 4.0.0.0/24 is subnetted, 1 subnets
B 4.4.4.0 [20/0] via 13.1.1.3, 00:34:34 5.0.0.0/24 is subnetted, 1 subnets
B 5.5.5.0 [20/0] via 13.1.1.3, 00:34:34
Local_Pref属性的用法和配置方法
保持基本配置不变,我们分别到R3、R4和R5上show ip bgp查看它们的BGP路由表表: R3
R3#show ip bgp
BGP table version is 9, local router ID is 3.3.3.3
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 * i1.1.1.0/24 10.1.1.1 0 100 0 1 i *> 13.1.1.1 0 0 1 i *>i2.2.2.0/24 24.1.1.2 0 100 0 2 i *> 3.3.3.0/24 0.0.0.0 0 32768 i *>i4.4.4.0/24 45.1.1.4 0 100 0 i *>i5.5.5.0/24 35.1.1.5 0 100 0 i R4
R4#show ip bgp
BGP table version is 41, local router ID is 4.4.4.4
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 * i1.1.1.0/24 13.1.1.1 0 100 0 1 i * 24.1.1.2 0 2 1 i *> 10.1.1.1 0 0 1 i *> 2.2.2.0/24 24.1.1.2 0 0 2 i
天津汤姆一通互联网技术训练中心
WWW.XUEXIZU.COM
*>i3.3.3.0/24 35.1.1.3 0 100 0 i *> 4.4.4.0/24 0.0.0.0 0 32768 i *>i5.5.5.0/24 45.1.1.5 0 100 0 i R5
R5#show ip bgp
BGP table version is 21, local router ID is 5.5.5.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 *>i1.1.1.0/24 10.1.1.1 0 100 0 1 i * i 13.1.1.1 0 100 0 1 i *>i2.2.2.0/24 24.1.1.2 0 100 0 2 i *>i3.3.3.0/24 35.1.1.3 0 100 0 i *>i4.4.4.0/24 45.1.1.4 0 100 0 i *> 5.5.5.0/24 0.0.0.0 0 32768 i
下面我们通过对R3的配置,设置从R1学到的1.1.1.0的本地优先级(Localpref)设置为200,由于缺省的值为100,AS345中所有的路由器都会选择R3到达1.1.1.0。
实验配置:
R3(config)#access-list 10 permit 1.1.1.0 0.0.0.255 R3(config)#route-map local_pref permit 10 R3(config-route-map)#match ip address 10 R3(config-route-map)#set local-preference 200 R3(config-route-map)#exit R3(config)#router bgp 345
R3(config-router)#neighbor 13.1.1.1 route-map local_pref in R3(config-router)#end
当配置完成后,我们分别在3台路由器上clear ip bgp * soft,然后在分别看它们的BGP表: R3
R3#show ip bgp
BGP table version is 10, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
天津汤姆一通互联网技术训练中心
WWW.XUEXIZU.COM
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 13.1.1.1 0 200 0 1 i *>i2.2.2.0/24 24.1.1.2 0 100 0 2 i *> 3.3.3.0/24 0.0.0.0 0 32768 i *>i4.4.4.0/24 45.1.1.4 0 100 0 i *>i5.5.5.0/24 35.1.1.5 0 100 0 i R4
R4#show ip bgp
BGP table version is 42, local router ID is 4.4.4.4
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 *>i1.1.1.0/24 13.1.1.1 0 200 0 1 i * 24.1.1.2 0 2 1 i * 10.1.1.1 0 0 1 i *> 2.2.2.0/24 24.1.1.2 0 0 2 i *>i3.3.3.0/24 35.1.1.3 0 100 0 i *> 4.4.4.0/24 0.0.0.0 0 32768 i *>i5.5.5.0/24 45.1.1.5 0 100 0 i R5
R5#show ip bgp
BGP table version is 22, local router ID is 5.5.5.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 *>i1.1.1.0/24 13.1.1.1 0 200 0 1 i *>i2.2.2.0/24 24.1.1.2 0 100 0 2 i *>i3.3.3.0/24 35.1.1.3 0 100 0 i *>i4.4.4.0/24 45.1.1.4 0 100 0 i *> 5.5.5.0/24 0.0.0.0 0 32768 i
因为Local_Pref属性作用范围是所在的本AS(这里为AS 345),可以看到,不仅R3原来默认的LocPrf属性值发生了变化,也改变了R4和R5的默认LocPrf属性值,并且R4和R5的1.1.1.0这个路由的下一跳变为13.1.1.1,也就是R3,成功地实现了用LocPrf属性来修改BGP的选路。
这里需要注意的是,R3在修改Local_Pref属性前,是从R1和R4学习到1.1.1.0网段的,
天津汤姆一通互联网技术训练中心