BGP路径属性之本地优先级local preference 实验分析
BGP路径属性之本地优先级(local preference)
本地优先级是公认自由决定的属性,它告诉AS中的路由器,哪条路径是离开AS的首选路径。
特点:
优先级属性用来影响IBGP邻居,告诉自己的IBGP邻居如何离开本AS
只能在本AS内传递,不能传给EBGP邻居
默认值=100
越大越好
GNS3实验分析路径属性origin
查看R4的bgp database
R4(config)#do show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 172.16.0.1/32 5.5.5.5 0 0 5 i
*> 172.16.1.1/32 5.5.5.5 0 0 5 i
*> 172.16.2.1/32 5.5.5.5 0 0 5 i
*> 172.16.3.1/32 5.5.5.5 0 0 5 i
* i192.168.0.1/32 3.3.3.3 0 100 0 1 i
*> i 2.2.2.2 0 100 0 1 i
实验部署
要求:192.168.0.1的路由默认走的是R2,通过修改Local Preference属性改为走R3
控制:IBGP邻居起作用,所以不能在R3与R4之间配置,只能在R1与R3之间配置
本实验以在R3上配置为例,将R3的Local Preference属性增大:
R3(config)#ip prefix-list LOCAL permit 192.168.0.1/32
R3(config)#route-map LOCAL permit 10
R3(config-route-map)#match ip address prefix-list LOCALR3(config-route-map)#set local-preference 200 //修改local-preference属性为200
R3(config-route-map)#exit
R3(config)#route-map LACAL permit 20
R3(config-route-map)#router bgp 234
R3(config-router)#nei 4.4.4.4 route-map LOCAL out修改完local-preference属性,再看R4的bgp database如下:
Network Next Hop Metric LocPrf Weight Path
*> 172.16.0.1/32 5.5.5.5 0 0 5 i
*> 172.16.1.1/32 5.5.5.5 0 0 5 i
*> 172.16.2.1/32 5.5.5.5 0 0 5 i
*> 172.16.3.1/32 5.5.5.5 0 0 5 i
*> i192.168.0.1/32 3.3.3.3 0 200 0 1 i
* i 2.2.2.2 0 100 0 1 i可以看到192.168.0.1从R3传来的路由属性Local Preference即LocPrf被修改成200
200比从R2传来的路由属性Local Preference 100大,所以最佳路由会选择走R3