使用 LOCAL_PREF MED 属性 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

一、 实验目的
使用local_pref med属性改变bgp行为,并且实现路由选择策略。
二、 拓扑结构图
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />
三、 实验步骤
1.       基本接口配置
步骤略
实验结果
isp1b#ping  <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />10.1.1.1  isp1b#ping 172.24.1.17
isp1a#ping 192.168.1.6

 

2.       配置bgp
sanjose3(config-if)#router bgp 100
sanjose3(config-router)#neigh 192.168.1.5 remote-as 200
sanjose3(config-router)#neigh 172.24.1.18 remote-as 400
sanjose3(config-router)#net 200.100.50.0
isp1a
router bgp 200
network 10.1.1.0 mask 255.255.255.252
 neighbor 10.1.1.2 remote-as 200
 neighbor 192.168.1.6 remote-as 100

 

isp1b
router bgp 400
network 10.1.1.0 mask 255.255.255.252
 neighbor 10.1.1.1 remote-as 200
 neighbor 172.24.1.17 remote-as 100

 

3.       配置本地优先级属性
isp1a#show ip route
B    200.100.50.0/24 [20/0] via 192.168.1.6, 00:00:21

     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial0/1
     192.168.1.0/30 is subnetted, 1 subnets
C       192.168.1.4 is directly connected, Serial0/0

 

isp1a#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/30      0.0.0.0                  0         32768 i
*                   192.168.1.6                            0 100 400 i
*                   10.1.1.2                 0             0 400 i
*> 200.100.50.0     192.168.1.6              0             0 100 i
*                   10.1.1.2                               0 400 100 i
通过配置本地优先级属性,是路由器采用另一条路径

 

isp1a(config)#route-map viaAS400         
isp1a(config-route-map)#set local-preference 150
isp1a(config-route-map)#router bgp 200
isp1a(config-router)#neigh 10.1.1.2 route-map viaAS400 in

 

查看结果:
isp1a#show ip route
B    200.100.50.0/24 [20/0] via 10.1.1.2, 00:00:06

     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial0/1
     192.168.1.0/30 is subnetted, 1 subnets
C       192.168.1.4 is directly connected, Serial0/0

 

isp1a#show ip bgp

 

   Network          Next Hop            Metric LocPrf Weight Path
*  10.1.1.0/30      192.168.1.6                            0 100 400 i
*                   10.1.1.2                 0    150      0 400 i
*>                  0.0.0.0                  0         32768 i
*  200.100.50.0     192.168.1.6              0             0 100 i

 

isp1a#show ip bgp 200.100.50.0
BGP routing table entry for 200.100.50.0/24, version 3
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:
  192.168.1.6
  100
    192.168.1.6 from 192.168.1.6 (200.100.50.1)
      Origin IGP, metric 0, localpref 100, valid, external
  400 100
    10.1.1.2 from 10.1.1.2 (172.24.1.18)
      Origin IGP, localpref 150, valid, external, best  可以发现本地优先级改变!!确实可以启动改变路由选择的作用,从本地优先级高的走!!
4.       配置MED属性
配置sanjose3med值使它向不同到AS发送不同的度量值,改变路由选择
isp1a(config)#route-map badmetric
isp1a(config-route-map)#set metric 150
isp1a(config-route-map)#router bgp 200
isp1a(config-router)#nei 192.168.1.6 route-map badmetric out

 

isp1b(config)#route-map badmetric
isp1b(config-route-map)#set metric 200
isp1b(config-route-map)#router bgp 400
isp1b(config-router)#neigh 172.24.1.17 route
isp1b(config-router)#neigh 172.24.1.17 route-map badmetric out

 

sanjose3(config)#router bgp 100
sanjose3(config-router)#bgp always-compare-med

 

查看实验结果:
sanjose3#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*  10.1.1.0/30      172.24.1.18            200             0 400 i
*>                  192.168.1.5            150             0 200 i
*> 200.100.50.0     0.0.0.0                  0         32768 i

 

sanjose3#show ip route
C    200.100.50.0/24 is directly connected, FastEthernet1/0
     172.24.0.0/30 is subnetted, 1 subnets
C       172.24.1.16 is directly connected, Serial0/1
     10.0.0.0/30 is subnetted, 1 subnets
B       10.1.1.0 [20/150] via 192.168.1.5, 00:00:44

     192.168.1.0/30 is subnetted, 1 subnets
C       192.168.1.4 is directly connected, Serial0/0
实验成功,从med值低的走,改变med值可以改变ebgp的路由选择!