路由映射实战二 
 本篇博文和上一篇是紧密结合的,只是在上个试验的基础上作了改动,达到其他的试验效果。
  试验二:
  在R1上增加一个网段,并发布路由。这里采用三种方法。 
 如下是第一种,是在试验一的基础上直接增加一个网段,发布路由。
 A(config)#int lo2
 A(config-if)#ip addr 192.168.30.1 255.255.255.0
 A(config-if)#exit
 A(config)#router eigrp 100
 A(config-router)#net 192.168.30.0
  分别在R2 ,R3上做测试: 
 正常情况下,
  R2上是能学习到路由,R3上不能学到路由。 
 B#
 B#show ip ro
 Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
        E1 - OSPF external type 1, E2 - OSPF external type 2
        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
        ia - IS-IS inter area, * - candidate default, U - per-user static route
        o - ODR, P - periodic downloaded static route
 Gateway of last resort is not set
  D    192.168.30.0/24 [90/2297856] via 202.110.100.1, 00:00:21, Serial1/0    //新学到的路由。 
 C    202.110.100.0/24 is directly connected, Serial1/0
 C    202.110.101.0/24 is directly connected, Serial1/1
 D    192.168.10.0/24 [90/2297856] via 202.110.100.1, 00:16:44, Serial1/0
 D    192.168.20.0/24 [90/2297856] via 202.110.100.1, 00:16:44, Serial1/0
 C>en
 C#show ip ro
 Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
        E1 - OSPF external type 1, E2 - OSPF external type 2
        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
        ia - IS-IS inter area, * - candidate default, U - per-user static route
        o - ODR, P - periodic downloaded static route
 Gateway of last resort is not set
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:18, Serial1/1
 R    192.168.20.0/24 [120/5] via 202.110.101.1, 00:00:18, Serial1/1
  解决方案:在B上重新做路由映射,及路由的再发布。 
 B(config)#route-map abc permit 30
 B(config-route-map)#match ip addr 3
 B(config-route-map)#set metric 10
 B(config-route-map)#exit
 B(config)#access-list 3 permit 192.168.30.0 0.0.0.255
 B(config)#router rip
 B(config-router)#redistribute eigrp 100 route-map abc
  在C上做测试; 
 C#show ip ro
 Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
        E1 - OSPF external type 1, E2 - OSPF external type 2
        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
        ia - IS-IS inter area, * - candidate default, U - per-user static route
        o - ODR, P - periodic downloaded static route
 Gateway of last resort is not set
 R    192.168.30.0/24 [120/10] via 202.110.101.1, 00:00:10, Serial1/1
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:10, Serial1/1
 R    192.168.20.0/24 [120/5] via 202.110.101.1, 00:00:10, Serial1/1
 第二种方法
 在访问控制列表中做文章,一个列表放两个路由,
 
  B(config)#route-map abc permit 20 
 B(config-route-map)#match ip addr 2
 B(config-route-map)#set metric 5
 B(config-route-map)#exit
 B(config)#access-list 2 permit 192.168.30.0  0.0.0.255
 B(config)#
 B(config)#router rip
 B(config-router)#redistribute eigrp 100 route-map abc
 B(config-router)#
  在C上再次做测试: 
 
C#show ip ro
 Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
        E1 - OSPF external type 1, E2 - OSPF external type 2
        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
        ia - IS-IS inter area, * - candidate default, U - per-user static route
        o - ODR, P - periodic downloaded static route
 Gateway of last resort is not set
 R    192.168.30.0/24 [120/5] via 202.110.101.1, 00:00:12, Serial1/1
  注意:学到的路由种子度量和20网段的种子度量相同。 
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:12, Serial1/1
 R    192.168.20.0/24 [120/5] via 202.110.101.1, 00:00:12, Serial1/1
 方法三:
  路由再发布时,满足1号表的路由,修改度量值为3,不满足1号表的路由,修改度量值为5.(即对有set无match的应用) 
 B(config)#route-map abc permit 10
 B(config-route-map)#match ip addr 1
 B(config-route-map)#set metric 3
 B(config)#route-map abc permit 20
 B(config-route-map)#no match ip addr 2
 B(config-route-map)#set metric 5
 这里还可以采用不配置20网段的访问控制列表,效果是一样的,并不冲突。
 
在C路由器上做测试:
 
R    192.168.30.0/24 [120/5] via 202.110.101.1, 00:00:12, Serial1/1
 R    202.110.100.0/24 [120/5] via 202.110.101.1, 00:00:12, Serial1/1
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:12, Serial1/1
 R    192.168.20.0/24 [120/5] via 202.110.101.1, 00:00:12, Serial1/1
  因为利用上一种方法时30网段的种子度量是5,此时30网段种子度量也是5,显然有点不清楚,下面利用同样的方法将30网段的种子度量该为3。由于利用再发布是一样的,所以只需要将10网段和20网段对应的match和set 调整一下即可。 
  在R2做操作: 
 B(config)#route-map abc permit 20
  B(config-route-map)# match ip addr 2     //启用20网段的match 
 B(config-route-map)#set metric 5
  R3上测试: 
  R    192.168.30.0/24 [120/3] via 202.110.101.1, 00:00:23, Serial1/1   //试验结果在我们预料之中。 
 R    202.110.100.0/24 [120/3] via 202.110.101.1, 00:00:23, Serial1/1
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:23, Serial1/1
 R    192.168.20.0/24 [120/3] via 202.110.101.1, 00:00:23, Serial1/1
 试验三:在发布过程中,满足1号表的路由,修改种子度量为3,满足2号表的路由,使用默认属性正常发布。
 R2上修改:(理解默认属性:即match和set均不配置)
 B(config-route-map)#route-map abc permit 10
 B(config-route-map)#no  match ip addr 1   
 B(config-route-map)#set metric 3
 B(config)#route-map abc permit 20
 B(config-route-map)#no  match ip addr 2
 B(config-route-map)#no set metric 5
 由于10网段在route-map abc permit 10  ,它里面包含的match和set语句,正常情况下,R3应该只能学到10网段的路由,而20,30网段属于默认属性,满足表2,应该学习不到路由。
 Gateway of last resort is not set
 C    202.110.101.0/24 is directly connected, Serial1/1
 R    192.168.10.0/24 [120/3] via 202.110.101.1, 00:00:08, Serial1/1
 试验现象和我们的理论分析完全吻合。
 有set无match的情况我们看到了,那么有match无set会怎样呢???
   
R3只能学到匹配10网段的路由。呵呵,学习!其乐无穷啊!!加油吧!
 
      本文转自shenleigang 51CTO博客,原文链接:http://blog.51cto.com/shenleigang/151090,如需转载请自行联系原作者