BGP选路策略――AS Path

BGP选路策略――AS Path
 
 
AS-Path    shortest AS-path
 
BGP路由每经过一个AS,就会将这个AS号加入自已的AS-Path中。
 
当一个路由器收到两条去往同一个目的地的路由,它将选择最短AS路径,到目标网络经过的AS最少的路由胜出
这个属性只能在EBGP邻居之间传路由时进行改动,对IBGP邻居传来的路由改不了
 
实验需求:R3通过R1访问172.16.1.0,通过R4访问192.168.1.0
 
需求分析:本例需要通过修改AS PATH实现路由选路策略,那根据AS PATH特性,我做了以下理解。在R4上规定R2把172网段的信息发来时增加它的AS PATH,然后告诉R3,R3比较R1和R4通往172网段的AS路径发现走R1近随即把数据包发给了R1。
 
再在R2上修改192.16.1.0网段的AS PATH告诉R1,“我到192网段需要经过好几个AS”。相同的信息,R3知道了。它比较后发现R1去目的地的AS PATH比R4的长,那就把发给192网段的数据包给了R4,解决 …… 验证
 
( 基本配置这里就不重复了, “BGP 选路策略 ――Weight” 中有 ......)
 
R4(config)#access-list 1 permit 172.16.1.0 0.0.0 .0
R4(config)#route-map R3-172
R4(config-route-map)#match ip add 1
R4(config-route-map)# set as-path prepend 1 1 1
//建议 加自已的AS号,不易搞混
R4(config-route-map)#exit
R4(config)#route-map R3-172 20
R4(config-route-map)#exit
R4(config)#router bgp 1
R4(config-router)#neighbor 24.1.1.2 route-map R3 -172 in
//从邻居24.1.1.2发过来的路由符合route-map R3-172,则增加AS Path
R4#clear ip bgp * soft
 
 
R2(config)#access-list 1 permit 192.168.1.0 0.0.0 .0
R2(config)#route-map R1-192
R2(config-route-map)#match ip address 1
R2(config-route-map)#set as-path prepend 1 1 1
R2(config-route-map)#exit
R2(config)#route-map R1-192 20
R2(config-route-map)#exit
R2(config)#router bgp 2
R2(config-router)#neighbor 12.1.1 .1 route-map R1-192 out
//发向邻居 12.1.1 .1的路由信息符合route-map R1-192,则增加AS Path
R2#clear ip bgp * soft
 
 
R3#sh ip bgp          
BGP table version is 13, 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 1 1 1 2 i
*>i                 13.1.1 .1                 0    100      0 2 i
*>i192.168.1.0      34.1.1.4                 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 164 msec 32 msec 92 msec
  2 12.1.1 .2 48 msec 132 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 132 msec 72 msec 104 msec
  2 24.1.1.2 116 msec 128 msec *
 

你可能感兴趣的:(网络,职场,路由,休闲,BGP)