2、掌握基于route-map的MED配置方法。
配置各路由器的IP地址,测试互连可达。
配置基本的BGP协议。
在“35.Using Route Maps to Configuring BGP Local Preference”中,介绍了如何使用本地优先配置数据如何流出本地自治系统,本实验介绍使用另一个BGP的属性即MED属性配置,影响其它自治系统的数据如何流入本地自治系统。
本实验仍关注BGP 64512中的那两个回环接口。
查看R3和R4的路由表:
R3>show ip route
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.1.1, 00:01:20
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/1
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [20/0] via 192.168.1.1, 00:00:53
C 192.168.1.0/24 is directly connected, Serial0/0
B 192.168.2.0/24 [200/0] via 10.1.1.2, 00:01:20
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.1.1, 00:01:20
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 1 subnets
B 172.16.1.0 [20/0] via 192.168.2.2, 00:01:58
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/1
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [20/0] via 192.168.2.2, 00:01:58
B 192.168.1.0/24 [200/0] via 10.1.1.1, 00:01:58
C 192.168.2.0/24 is directly connected, Serial0/0
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.2.2, 00:01:58
这里假设R1和R4之间的链路是100Mbps的以太网,其它的都是2Mbps的串行链路,得出下表信息: (S:Serial F:FastEthernet Lo:Loopback) R3---(S)--->R2---(Lo)--->150.150.1.0/24 R3---(S)--->R2---(S)---->R1---(Lo)--->130.130.1.0/24 R3---(S)--->R4---(F)---->R1---(Lo)--->130.130.1.0/24 R4---(F)--->R1---(Lo)--->130.130.1.0/24 R4---(F)--->R1---(S)---->R2---(Lo)--->150.150.1.0/24 R4---(S)--->R3---(S)---->R2---(Lo)--->150.150.1.0/24 按以上表可以看出,R3到130.130.1.0/24的最佳路径应该是: R3---(S)--->R4---(F)---->R1---(Lo)--->130.130.1.0/24 但是它选择了一条次佳路由(可能会产生拥塞),如果选择通过R4路由,则可以大大地缓解这个问题。 可以在R1和R2上配置MED属性,因为MED属性可以实现:影响其它自治系统的数据流如何流入本自治系统。 MED属性值越低越优先选择,MED值默认为0。 可以在R2上配置其向R3通告的130.130.1.0/24网络的路由的MED值高于默认值即可。 为了能够观察到MED值配置前后路由的变化,需要先看下R3和R4的BGP数据库表: R3>show ip bgp Network Next Hop Metric LocPrf Weight Path R4>show ip bgp Network Next Hop Metric LocPrf Weight Path 在R2上配置对特定网络路由的MED修改: R2(config)#access 1 per 130.130.1.0 0.0.0.255 ---->定范围 再查看R3和R4的BGP数据库: R3>show ip bgp Network Next Hop Metric LocPrf Weight Path ---->MED值改变,导致下一跳改为192.168.2.2 R4>show ip bgp Network Next Hop Metric LocPrf Weight Path ---->不能影响到R4,因为MED属性为不可传递属性 为了确切的判断出R3到达130.130.1.0/24的网络路由,使用的是最佳路由,在R4路由器上配置下一跳属性: R4(config)#router bgp 64513 查看R3上的BGP数据库和路由表: R3>show ip bgp Network Next Hop Metric LocPrf Weight Path R3>show ip route 172.16.0.0/24 is subnetted, 1 subnets 跟踪情况: R3#trace 130.130.1.1 Type escape sequence to abort. 1 10.1.1.2 40 msec 28 msec 20 msec 到此,一切OK。
BGP table version is 8, local router ID is 192.168.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 130.130.1.0/24 192.168.1.1 0 64512 i
* i 192.168.2.2 0 100 0 64512 i
* i150.150.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* i172.16.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* 192.168.1.0 192.168.1.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.1.1 0 64512 i
*>i 10.1.1.2 0 100 0 i
BGP table version is 8, local router ID is 192.168.2.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
* i10.1.1.0/24 10.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
* i130.130.1.0/24 192.168.1.1 0 100 0 64512 i
*> 192.168.2.2 0 0 64512 i
* i150.150.1.0/24 192.168.1.1 0 100 0 64512 i
*> 192.168.2.2 0 64512 i
* i172.16.1.0/24 192.168.1.1 0 100 0 64512 i
*> 192.168.2.2 0 0 64512 i
*>i192.168.1.0 10.1.1.1 0 100 0 i
* 192.168.2.2 0 64512 i
* 192.168.2.0 192.168.2.2 0 0 64512 i
*> 0.0.0.0 0 32768 i
R2(config)#route-map set-med per 10 ---->映射表10
R2(config-route-map)#match ip add 1 ---->使用范围
R2(config-route-map)#set metric 100 ---->设置MED值在这里,在思科的设备中MED值就是metric
R2(config-route-map)#exit
R2(config)#route-map set-med per 20 ---->允许所有
R2(config-route-map)#exit
R2(config)#router bgp 64512
R2(config-router)#neighbor 192.168.1.2 route-map set-med out ---->使用映射表
R2(config-router)#end
R2#clear ip bgp * soft out ---->刷新外出的策略配置,加快收敛
BGP table version is 9, local router ID is 192.168.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* 130.130.1.0/24 192.168.1.1 100 0 64512 i ---->MED值低的优先
*>i 192.168.2.2 0 100 0 64512 i
* i150.150.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* i172.16.1.0/24 192.168.2.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* 192.168.1.0 192.168.1.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.1.1 0 64512 i
*>i 10.1.1.2 0 100 0 i
BGP table version is 8, local router ID is 192.168.2.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
* i10.1.1.0/24 10.1.1.1 0 100 0 i
*> 0.0.0.0 0 32768 i
*> 130.130.1.0/24 192.168.2.2 0 0 64512 i
* i150.150.1.0/24 192.168.1.1 0 100 0 64512 i
*> 192.168.2.2 0 64512 i
* i172.16.1.0/24 192.168.1.1 0 100 0 64512 i
*> 192.168.2.2 0 0 64512 i
*>i192.168.1.0 10.1.1.1 0 100 0 i
* 192.168.2.2 0 64512 i
* 192.168.2.0 192.168.2.2 0 0 64512 i
*> 0.0.0.0 0 32768 i
R4(config-router)#neighbor 10.1.1.1 next-hop-self
R4(config-router)#end
BGP table version is 10, local router ID is 192.168.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
* i10.1.1.0/24 10.1.1.2 0 100 0 i
*> 0.0.0.0 0 32768 i
* 130.130.1.0/24 192.168.1.1 100 0 64512 i
*>i 10.1.1.2 0 100 0 64512 i ---->已改
* i150.150.1.0/24 10.1.1.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* i172.16.1.0/24 10.1.1.2 0 100 0 64512 i
*> 192.168.1.1 0 0 64512 i
* 192.168.1.0 192.168.1.1 0 0 64512 i
*> 0.0.0.0 0 32768 i
* 192.168.2.0 192.168.1.1 0 64512 i
*>i 10.1.1.2 0 100 0 i
Gateway of last resort is not set
B 172.16.1.0 [20/0] via 192.168.1.1, 01:00:04
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial0/1
130.130.0.0/24 is subnetted, 1 subnets
B 130.130.1.0 [200/0] via 10.1.1.2, 00:03:29 ---->已经按预定的修改下一跳
C 192.168.1.0/24 is directly connected, Serial0/0
B 192.168.2.0/24 [200/0] via 10.1.1.2, 01:00:04
150.150.0.0/24 is subnetted, 1 subnets
B 150.150.1.0 [20/0] via 192.168.1.1, 01:00:04
Tracing the route to 130.130.1.1
2 192.168.2.2 52 msec * 64 msec