2路由策略_route-map(执行路由策略)

拓扑图:
配置参数:
R1
access-list 10 permit 192.168.5.0 0.0.0.255 // 配置匹配的流量
route-map ospf permit 10 // 创建一个路由图配置要匹配的流量
 match ip address 10  // 关联要匹配的流量
 set metric 1 // 设置匹配流量的度量值为 1
route-map ospf permit 20 // 接着用上面的路由图,配置序号为 20 ,设置其它的流量
 set metric 2 // 设置其它的流量的度量值为 2
router ospf 1
redistribute rip subnets // OSPF 里重发布 RIP ,让 R4 可以学习到
 network 192.168.3.0 0.0.0.255 area 0
router rip
 version 2
 redistribute ospf 1 route-map ospf // RIP 里重发布 OSPF ,并应用上面配置好的路由图,达到 分流 (两台设备 [R1,R3] 配置不同的度量值)和热备(动态路由可以动态感知网络拓扑的变化,动态的将度量值小的路由装进路由表)的效果 !!!
 network 192.168.1.0
 no auto-summary
 
R2:
access-list 20 permit 192.168.6.0 0.0.0.255
route-map ospf permit 10
 match ip address 20
 set metric 1
route-map ospf permit 20
 set metric 2
router ospf 1
redistribute rip subnets
 network 192.168.4.0 0.0.0.255 area 0
router rip
 version 2
 redistribute ospf 1 route-map ospf
 network 192.168.2.0
 no auto-summary
测试:
r5#sh ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.100.2   YES NVRAM  up                    up     
r5#traceroute 192.168.5.1
  1 192.168.100.1 1032 msec 20 msec 4 msec
  2 192.168.1.2 16 msec 8 msec 60 msec
  3 192.168.3.2 32 msec 12 msec *
r5#traceroute 192.168.6.1
  1 192.168.100.1 32 msec 16 msec 16 msec
  2 192.168.2.2 12 msec 28 msec 32 msec
  3 192.168.4.2 16 msec 32 msec *
r5#
可以看出要去 192.168.5.0 的网络走左边,去 192.168.6.0 的网络走右边!!!
 
配置成功后路由表是这样的:
R2:
R    192.168.4.0/24 [120/2] via 192.168.2.2, 00:00:17, Ethernet1/1
                    [120/2] via 192.168.1.2, 00:00:11, Ethernet1/0
     192.168.5.0/32 is subnetted, 1 subnets
R       192.168.5.1 [120/1] via 192.168.1.2, 00:00:11, Ethernet1/0
     192.168.6.0/32 is subnetted, 1 subnets
R       192.168.6.1 [120/1] via 192.168.2.2, 00:00:17, Ethernet1/1
C    192.168.1.0/24 is directly connected, Ethernet1/0
C    192.168.2.0/24 is directly connected, Ethernet1/1
C    192.168.100.0/24 is directly connected, FastEthernet0/0
R    192.168.3.0/24 [120/2] via 192.168.2.2, 00:00:17, Ethernet1/1
                    [120/2] via 192.168.1.2, 00:00:11, Ethernet1/0
可以看出, R2 通过 R1 学习到 192.168.5.0 并且为 1 跳,通过 R3 学习到 192.168.6.0 并且为 1 跳。
现在来测试一下,将 R1 E0/0 (连着 R4 的接口) down 掉,看看会发现什么现象:
R1:
r1(config)#int e0/0
r1(config-if)#sh
r1(config-if)#shutdown
R2:
r2#sh ip rou
R    192.168.4.0/24 [120/2] via 192.168.2.2, 00:00:12, Ethernet1/1
     192.168.5.0/32 is subnetted, 1 subnets
R       192.168.5.1 [120/2] via 192.168.2.2, 00:00:12, Ethernet1/1
     192.168.6.0/32 is subnetted, 1 subnets
R       192.168.6.1 [120/1] via 192.168.2.2, 00:00:12, Ethernet1/1
C    192.168.1.0/24 is directly connected, Ethernet1/0
C    192.168.2.0/24 is directly connected, Ethernet1/1
C    192.168.100.0/24 is directly connected, FastEthernet0/0
R    192.168.3.0/24 [120/2] via 192.168.2.2, 00:00:12, Ethernet1/1
r2#
可以看出 R2 是通过 R3 学习到的 192.168.5.0 的路由的,它的跳数为 2 R5 要去 192.168.5.0 的路由要走右边,因为左边的 R1 的上连端口 down 掉了。这样达到了热备的效果!!!
 
现在把 R1 E0/0 再开启,看看会是什么效果:
R1:
r1(config)#int e0/0
r1(config-if)#no shutdown
R2:
r2#  SH IP ROU
R    192.168.4.0/24 [120/2] via 192.168.2.2, 00:00:05, Ethernet1/1
                    [120/2] via 192.168.1.2, 00:00:25, Ethernet1/0
     192.168.5.0/32 is subnetted, 1 subnets
R       192.168.5.1 [120/1] via 192.168.1.2, 00:00:25, Ethernet1/0
     192.168.6.0/32 is subnetted, 1 subnets
R       192.168.6.1 [120/1] via 192.168.2.2, 00:00:05, Ethernet1/1
C    192.168.1.0/24 is directly connected, Ethernet1/0
C    192.168.2.0/24 is directly connected, Ethernet1/1
C    192.168.100.0/24 is directly connected, FastEthernet0/0
R    192.168.3.0/24 [120/2] via 192.168.2.2, 00:00:05, Ethernet1/1
                    [120/2] via 192.168.1.2, 00:00:25, Ethernet1/0
r2#
可以看出, R2 通过动态路由感知到网络拓扑的变化,动态地学习到了度量值优的路由,然后入进入路由表里!!!

你可能感兴趣的:(GNS3,rip,动态路由,ospf,网络互联)