BGP选路策略——Local Preference
 
 
Local Preference  (比谁大)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

本地优先级是公认自由决定的属性,它告诉AS中的路由器,哪条路径是离开AS的首选路径。所以,一般设置在AS的边界路由器上。

 

特点:

·告诉自己的IBGP邻居如何离开本AS

·只能在本AS内传递。

·默认值100 (show 明细路由才能显示,如:sh ip bgp 172.16.1.0)

 

R1(config-router)#bgp default local-preference 101

//会影响AS内所有路由,将本地缺省路由改为101

 
这条命令打上后,本地的值就会变,但必须show明细才能看得到

打上这一命令后----

·对"EBGP传过来的路由"\"自己network的路由"起效,要show明细才能看到。

·对"IBGP传过来的路由"\"汇总路由"不起效

 

这里我们还是用抓取路由的方法来做。

 

实验需求:R3通过R1访问172.16.1.0网段,通过R4访问192.168.1.0网段

 

需求分析:local preference建议配置在AS的边界路由器上,在weight相同的情况下进行比较,看谁的优先级大。在R1上将R3访问172网段的优先级修改为200,在R4上将R3访问192网段的优先级改为250(如果改的比172网段的小或者相同,那R3还是会通过R1访问192R1router-idR4的小……

 
(基本配置这里就不重复了,“BGP选路策略——Weight”中有......)
 
R1(config)#access-list 1 permit 172.16.1.0 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />0.0.0.0
R1(config)#route-map R3-172
R1(config-route-map)#match ip add 1
R1(config-route-map)#set local-preference 200
R1(config-route-map)#exit
R1(config)#route-map R3-172 permit 20
R1(config-route-map)#exit
R1(config)#router bgp 1
R1(config-router)#neighbor 13.1.1.3 route-map R3-172 out
//邻居13.1.1.3发来的数据包应用route-map R3-172

 

R4(config)#access-list 1 permit 192.168.1.0 0.0.0.0
R4(config)#route-map R3-192
R4(config-route-map)#match ip add 1
R4(config-route-map)#set local-preference 250
R4(config-route-map)#exit
R4(config)#route-map R3-192 20
R4(config-route-map)#exit
R4(config)#router bgp 1
R4(config-router)#neighbor 34.1.1.3 route-map R3-192 out

 

 

===================验证==========================
R3#clear ip bgp * soft     //别忘了啊......
R3#sh 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

 

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      0.0.0.0                  0         32768 i
* i172.16.1.0/24    34.1.1.4                 0    100      0 2 i
*>i                 13.1.1.1                 0    200      0 2 i
*>i192.168.1.0      34.1.1.4                 0    250      0 2 i
* i                 13.1.1.1                 0    100      0 2 i

 

R3#traceroute 172.16.1.1 source 10.1.1.1

 

Type escape sequence to abort.
Tracing the route to 172.16.1.1

 

  1 13.1.1.1 36 msec 40 msec 140 msec

  2 12.1.1.2 132 msec 40 msec *

 

R3#traceroute 192.168.1.1 source 10.1.1.1

 

Type escape sequence to abort.
Tracing the route to 192.168.1.1

 

  1 34.1.1.4 136 msec 108 msec 44 msec

  2 24.1.1.2 64 msec 112 msec *