实验目的:
1、掌握基于Route-map的路由过滤配置方法。
2、掌握route-map的命令语法。
实验拓扑:
步骤1:接口ip配置+路由协议基础配置+重分发详见CSDNhttps://mp.csdn.net/mp_blog/creation/editor/125018583查看R1、R3路由表
R1#show ip route Gateway of last resort is not set1.0.0.0/24 is subnetted, 4 subnets
C 1.1.0.0 is directly connected, Loopback0
C 1.1.1.0 is directly connected, Loopback1
C 1.1.2.0 is directly connected, Loopback2
C 1.1.3.0 is directly connected, Loopback33.0.0.0/24 is subnetted, 4 subnets
O E2 3.3.0.0 [110/200] via 12.12.12.2, 03:39:53, FastEthernet0/0
O E2 3.3.1.0 [110/200] via 12.12.12.2, 03:39:53, FastEthernet0/0
O E2 3.3.2.0 [110/200] via 12.12.12.2, 03:04:37, FastEthernet0/0
O E2 3.3.3.0 [110/200] via 12.12.12.2, 03:04:38, FastEthernet0/023.0.0.0/24 is subnetted, 1 subnets
O E2 23.23.23.0 [110/200] via 12.12.12.2, 03:39:55, FastEthernet0/012.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, FastEthernet0/0
R3#show ip route Gateway of last resort is not set1.0.0.0/32 is subnetted, 4 subnets
R 1.1.1.1 [120/10] via 23.23.23.2, 00:00:14, FastEthernet0/1
R 1.1.0.1 [120/10] via 23.23.23.2, 00:00:14, FastEthernet0/1
R 1.1.3.1 [120/10] via 23.23.23.2, 00:00:14, FastEthernet0/1
R 1.1.2.1 [120/10] via 23.23.23.2, 00:00:14, FastEthernet0/13.0.0.0/24 is subnetted, 4 subnets
C 3.3.0.0 is directly connected, Loopback0
C 3.3.1.0 is directly connected, Loopback1
C 3.3.2.0 is directly connected, Loopback2
C 3.3.3.0 is directly connected, Loopback323.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/112.0.0.0/24 is subnetted, 1 subnets
R 12.12.12.0 [120/10] via 23.23.23.2, 00:00:16, FastEthernet0/1
步骤2:根据拓扑需要,在R2上配置路由过滤,以过滤ospf路由:
R2(config)#access-list 1 deny 1.1.0.0 0.0.0.255
R2(config)#access-list 1 deny 1.1.1.0 0.0.0.255
R2(config)#access-list 1 permit any R2(config)#route-map ospf_to_rip permit 10
//创建route-map并设定其名称为ospf_to_rip。
//其permit 10意思是指,如果下述match命令后面指定的条件成立的话,则其动作为允许。
//类似于ACL的permit。而且route-map跟ACL相同的是,在尾部也有隐藏的默认拒绝所有的条件。
R2(config-route-map)#match ip address 1R2(config)#router rip
R2(config-router)#redistribute ospf 1 metric 10 route-map ospf_tp_rip
//在路由重布时,引用刚才配置route-map对重发布的路由进行过滤。
查看R3的路由,确认路由的学习
R3#show ip route Gateway of last resort is not set1.0.0.0/32 is subnetted, 2 subnets
//通过配置路由过滤后, R3将不能够学习到被拒绝的两条路由。
R 1.1.3.1 [120/10] via 23.23.23.2, 00:00:01, FastEthernet0/1
R 1.1.2.1 [120/10] via 23.23.23.2, 00:00:01, FastEthernet0/13.0.0.0/24 is subnetted, 4 subnets
C 3.3.0.0 is directly connected, Loopback0
C 3.3.1.0 is directly connected, Loopback1
C 3.3.2.0 is directly connected, Loopback2
C 3.3.3.0 is directly connected, Loopback323.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected, FastEthernet0/112.0.0.0/24 is subnetted, 1 subnets
R 12.12.12.0 [120/10] via 23.23.23.2, 00:00:02, FastEthernet0/1
步骤3:配置R2过滤RIP的路由:
//本次使用permit方式进行匹配。
R2(config)#access-list 2 permit 3.3.2.0 0.0.0.255
R2(config)#access-list 2 permit 3.3.3.0 0.0.0.255R2(config)#route-map rip_to_ospf permit 20
R2(config-route-map)#match ip address 2
R2(config)#router ospf 1
R2(config-router)#redistribute rip metric 200 subnets route-map rip_to_ospf
查看R1路由表:
R1#show ip route Gateway of last resort is not set1.0.0.0/24 is subnetted, 4 subnets
C 1.1.0.0 is directly connected, Loopback0
C 1.1.1.0 is directly connected, Loopback1
C 1.1.2.0 is directly connected, Loopback2
C 1.1.3.0 is directly connected, Loopback33.0.0.0/24 is subnetted, 2 subnets
O E2 3.3.0.0 [110/200] via 12.12.12.2, 00:00:01, FastEthernet0/0
O E2 3.3.1.0 [110/200] via 12.12.12.2, 00:00:01, FastEthernet0/012.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected, FastEthernet0/0