【理论准备】

 
default local-preference value  default local-preference命令用来配置本地优先级的缺省值
 
default med命令用来配置系统MED的缺省值。undo default med命令用来恢复缺省值。
 
缺省情况下,MED的缺省值为0。
 
多出口区分(MED)属性是一个路由的外部度量(Metric),与本地优先级属性不同,MED在自治系统间交换,但进入自治系统的MED不会再发送到该自治系统以外。MED属性用于选
 
择最佳路由,MED较小的路由被选择。当一个运行BGP的路由器通过不同的外部对等体(External Peer)得到目的地址相同、下一跳不同的路由时,将根据不同路由的MED值进行优
 
先选择。在其它条件相同的情况下,MED较小的路由作为自治系统的外部路由。
 
 
 
【实验拓扑和软件】
 
 

 

 
 本文实验采用的交换机是H3C模拟器,下载地址如下:http://forum.h3c.com/forum.php? mod=viewthread&tid=109740&highlight=H3C%E6%A8%A1%E6%8B%9F%E5%99%A8 有兴趣的朋 
 
友可以在论坛上去下载 
【实验过程】
 
 
配置完成后,R1到10.1.5.1的路由的下一跳是R2上的10.1.1.2,而 10.1.2.2 并不是最佳路由,请看下面的路由表
 
 
 
[R1]dis bgp ro
 
 Total Number of Routes: 7
 
 BGP Local router ID is 10.0.0.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
 
 *>  10.0.0.1/32        0.0.0.0         0                     0       i
 *   10.1.1.0/24        10.1.1.2        0                     0       200i
 *   10.1.2.0/24        10.1.2.2        0                     0       200i
 *>  10.1.3.0/24        10.1.1.2        0                     0       200i
 *>  10.1.4.0/24        10.1.2.2        0                     0       200i
 *>  10.1.5.1/32        10.1.1.2                              0       200i
 *                      10.1.2.2                              0       200i
 
[R1]dis ip ro
Routing Tables: Public
        Destinations : 12       Routes : 12
 
Destination/Mask    Proto  Pre  Cost         NextHop         Interface
 
10.0.0.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.1.0/24         Direct 0    0            10.1.1.1        S0/6/0
10.1.1.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.1.2/32         Direct 0    0            10.1.1.2        S0/6/0
10.1.2.0/24         Direct 0    0            10.1.2.1        S0/6/1
10.1.2.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.3.0/24         BGP    255  0            10.1.1.2        S0/6/0
10.1.4.0/24         BGP    255  0            10.1.2.2        S0/6/1
10.1.4.1/32         Direct 0    0            10.1.4.1        S0/6/1
10.1.5.1/32         BGP    255  0            10.1.1.2        S0/6/0
127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0
127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0
 
 
 
去10.1.5.1/32 的  下一跳是  10.1.1.2 
 
配置BGP选路
 
 
 
[R2-bgp]default me
[R2-bgp]default med 10
[R2-bgp]
 
[R3-bgp]default local-preference 200
[R3-bgp]
 
 
R2的默认MED改成10 在同一AS内选择MED值小的作为出口,R3的默认med为0 则把R3作了默认出口,R3的local-preference值更改为200,则在进入as 200时,从R3进入。
 
<R1>dis ip ro
Routing Tables: Public
        Destinations : 12       Routes : 12
 
Destination/Mask    Proto  Pre  Cost         NextHop         Interface
 
10.0.0.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.1.0/24         Direct 0    0            10.1.1.1        S0/6/0
10.1.1.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.1.2/32         Direct 0    0            10.1.1.2        S0/6/0
10.1.2.0/24         Direct 0    0            10.1.2.1        S0/6/1
10.1.2.1/32         Direct 0    0            127.0.0.1       InLoop0
10.1.3.0/24         BGP    255  10           10.1.1.2        S0/6/0
10.1.4.0/24         BGP    255  0            10.1.2.2        S0/6/1
10.1.4.1/32         Direct 0    0            10.1.4.1        S0/6/1
10.1.5.1/32         BGP    255  0            10.1.2.2        S0/6/1
127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0
127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0
 
<R1>dis bgp ro
 
 Total Number of Routes: 7
 
 BGP Local router ID is 10.0.0.1 
 Status codes: * - valid, > - best, d - damped,
               h - history,  i - internal, s - suppressed, S - Stale
               Origin : i - IGP, e - EGP, ? - incomplete
     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
 
 *>  10.0.0.1/32        0.0.0.0         0                     0       i
 *   10.1.1.0/24        10.1.1.2        10                    0       200i
 *   10.1.2.0/24        10.1.2.2        0                     0       200i
 *>  10.1.3.0/24        10.1.1.2        10                    0       200i
 *>  10.1.4.0/24        10.1.2.2        0                     0       200i
 *>  10.1.5.1/32        10.1.2.2                              0       200i
 *                      10.1.1.2        10                    0       200i
 
<R1>
<R1>
<R1>
<R1>
 
 
10.1.5.1/32   下一跳是10.1.2.2    已经成功实验完成
 
【配置文本】