BGP选路原则(2)-local-preference

2、修改local preference改变选路

默认情况下R4bgp表中:

R4#sh ip bgp

BGP table version is 2, local router ID is 44.44.44.44

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       34.1.1.3                               0 23 1 i

*>                24.1.1.2                               0 23 1 i

修改local_preference改变选路

R4

R4(config)#ip prefix-list 1 per 1.1.1.0/24

R4(config)#route-map local-pref per 10

R4(config-route-map)#mat ip add prefix-list 1

R4(config-route-map)#set local-preference 200

R4(config)#router bgp 4

R4(config-router)#nei 34.1.1.3 route-map local-pref in

 

R4 BGP表:

R4#sh ip bgp

BGP table version is 3, local router ID is 44.44.44.44

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       24.1.1.2                               0 23 1 i

*>                  34.1.1.3                      200      0 23 1 i

 

如果在此基础上我们修改R2过来路由的weight,来比较weightlocal-preference的优先级

R4

R4(config)#ip prefix-list 2 per 1.1.1.0/24

R4(config)#route-map weight per 20

R4(config-route-map)#mat ip add prefix-list 2

R4(config-route-map)#set weight 100

R4(config)#router bgp 4

R4(config-router)#nei 24.1.1.2 route-map weight in

 

BGP表:

R4#sh ip bgp

BGP table version is 2, local router ID is 44.44.44.44

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       34.1.1.3                      200      0 23 1 i

*>                  24.1.1.2                             100 23 1 i

Weight的优先级确实比local-preference高。