实验步骤及要求:
1、 配置各台路由器的IP地址,并且使用ping命令确认各路由器的直连口的互通性。
2、 按照拓扑配置OSPF和RIPv2的路由协议,并关闭RIPv2的自动汇总。
3、 在R2上配置路由重发布。
4、 查看R1 和R3 的路由表。
R1#sho ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 6 subnets, 3 masks
O 172.16.255.0/30 [110/128] via 172.16.255.2, 00:00:51, Serial1/0
C 172.16.255.0/24 is directly connected, Serial1/0
C 172.16.1.0/24 is directly connected, Loopback1
C 172.16.0.1/32 is directly connected, Loopback0
C 172.16.2.0/24 is directly connected, Loopback2
C 172.16.3.0/24 is directly connected, Loopback3
O E2192.168.255.0/24 [110/20] via 172.16.255.2, 00:00:52, Serial1/0
O E2192.168.0.0/24 [110/20] via 172.16.255.2, 00:00:52, Serial1/0
O E2192.168.1.0/24 [110/20] via 172.16.255.2, 00:00:52, Serial1/0
O E2192.168.2.0/24 [110/20] via 172.16.255.2, 00:00:52, Serial1/0
O E2192.168.3.0/24 [110/20] via 172.16.255.2, 00:00:52, Serial1/0
R3#sho ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 6 subnets, 3 masks
R 172.16.255.0/30 [120/3] via192.168.255.2, 00:00:24, Serial1/0
R 172.16.255.0/24 [120/3] via192.168.255.2, 00:00:24, Serial1/0
R 172.16.1.1/32 [120/3] via 192.168.255.2,00:00:24, Serial1/0
R 172.16.0.1/32 [120/3] via 192.168.255.2,00:00:24, Serial1/0
R 172.16.3.1/32 [120/3] via 192.168.255.2,00:00:24, Serial1/0
R 172.16.2.1/32 [120/3] via 192.168.255.2,00:00:24, Serial1/0
C 192.168.255.0/24 is directly connected, Serial1/0
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Loopback1
C 192.168.2.0/24 is directly connected, Loopback2
C 192.168.3.0/24 is directly connected, Loopback3
5.根据拓扑的需要,在R2上配置路由过滤,以过滤ospf的路由,配置如下:
R2(config)#access-list 1 deny 172.16.0.0 0.0.0.255
R2(config)#access-list 1 deny 172.16.1.0 0.0.0.255
R2(config)#access-list 1 permit any
R2(config)#route-map ospftorip permit 10 创建route-map并命名为ospftorip,permit 10指,若下述match命令后指定的条件成立的话,则其动作为允许,在尾部也有隐藏的默认拒绝所有的条件。
R2(config-route-map)#match ip address 1 匹配acl 1所指定的网络
R2(config-route-map)#exit
R2(config)#router rip
R2(config-router)#redistribute ospf 1 metric 10 route-map ospftorip 在路由重发布时,引用刚才配置的route-map对重发不的路由进行过滤。
6、查看R3 的路由,确认路由的学习:
R3#sho ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 6subnets, 3 masks
R 172.16.255.0/30 [120/10] via 192.168.255.2,00:00:19, Serial1/0 通过路由的过滤R3
R 172.16.255.0/24 [120/10] via 192.168.255.2,00:00:19, Serial1/0 不能学习被过滤的路由
R 172.16.3.1/32 [120/10] via 192.168.255.2,00:00:19, Serial1/0
R 172.16.2.1/32 [120/10] via 192.168.255.2,00:00:19, Serial1/0
C 192.168.255.0/24 is directly connected, Serial1/0
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Loopback1
C 192.168.2.0/24 is directly connected, Loopback2
7、配置R2过滤RIP的路由:
R2(config)#access-list 2 permit 192.168.2.0 0.0.0.255
R2(config)#access-list 2 permit 192.168.3.0 0.0.0.255
R2(config)#route-map riptoospf deny 10 此处使用deny 10作为route-map的动作关键字
R2(config-route-map)#match ip address 2 指定需要deny的条件
R2(config-route-map)#exit
R2(config)#route-map riptoospf permit 20 再次创建动作关键字为permit 20的route-map,匹配所有
R2(config-route-map)#exit
R2(config)#router ospf 1
R2(config-router)#redistribute rip metric 20 subnets route-map riptoospf重发布时引用
8、查看R1 的路由表:
R1#sho ip route
Gateway of last resort is not set
172.16.0.0/16 is variably subnetted, 6subnets, 3 masks
O 172.16.255.0/30 [110/128] via 172.16.255.2, 00:26:59, Serial1/0
C 172.16.255.0/24 is directly connected, Serial1/0
C 172.16.1.0/24 is directly connected, Loopback1
C 172.16.0.1/32 is directly connected, Loopback0
C 172.16.2.0/24 is directly connected, Loopback2
C 172.16.3.0/24 is directly connected, Loopback3
O E2192.168.255.0/24 [110/20] via 172.16.255.2, 00:27:00, Serial1/0
O E2192.168.0.0/24 [110/20] via 172.16.255.2, 00:27:00, Serial1/0 被过滤后的路由表内容
O E2192.168.1.0/24 [110/20] via 172.16.255.2, 00:27:00, Serial1/0