用route-map筛选路由更新进而过滤路由

简介:
6
 
 
二、在上一个实验当中,我们用了distribute来筛选路由更新,那么这次我们用route-map来做一下,前期工作还是一样,配置各接口的IP和协议,并且在R2上做重分发,为了让R1R3学到明细路由我们要在R2关闭RIP的自动汇总
 
三、针对 OSPF区域的配置步骤:
1、配置完 IP和协议之后,先来看一下 R1的路由表:
R1#sh ip route
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
 
     172.168.0.0/24 is subnetted, 4 subnets
C       172.168.0.0 is directly connected, Loopback0
C       172.168.1.0 is directly connected, Loopback0
C       172.168.2.0 is directly connected, Loopback0
C       172.168.3.0 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.255.0 is directly connected, Serial1/1
O E2 192.168.255.0/24 [110/200] via 172.16.255.2, 00:00:16, Serial1/1
O E2 192.168.0.0/24 [110/200] via 172.16.255.2, 00:00:16, Serial1/1
O E2 192.168.1.0/24 [110/200] via 172.16.255.2, 00:00:16, Serial1/1
O E2 192.168.2.0/24 [110/200] via 172.16.255.2, 00:00:16, Serial1/1
O E2 192.168.3.0/24 [110/200] via 172.16.255.2, 00:00:16, Serial1/1   (没做过滤之前学到了5条O E2 型路由)
2、再来看一下 R3的路由表:
R3#sh ip route
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
 
     172.168.0.0/16 is variably subnetted, 4 subnets, 2 masks
R       172.168.1.0/24 [120/10] via 192.168.255.2, 00:00:24, Serial1/0
R       172.168.0.1/32 [120/10] via 192.168.255.2, 00:00:24, Serial1/0
R       172.168.2.0/24 [120/10] via 192.168.255.2, 00:00:24, Serial1/0
R       172.168.3.0/24 [120/10] via 192.168.255.2, 00:00:24, Serial1/0
     172.16.0.0/24 is subnetted, 1 subnets
R       172.16.255.0 [120/10] via 192.168.255.2, 00:00:24, Serial1/0     (没做过滤之前学到了5条R型路由)  
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, Loopback0
C    192.168.2.0/24 is directly connected, Loopback0
C    192.168.3.0/24 is directly connected, Loopback0
3、那么我在 R2做上针对 rip重分发到 ospf区域的访问控制列表,并且在 route-map上调用,然后再引用 route-map对重分发的路由进行过滤。
R2(config)#access-list 1 deny 192.168.2.0 0.0.0.255
R2(config)#access-list 1 deny 192.168.3.0 0.0.0.255
R2(config)#access-list 1 permit any
R2(config)#route-map rip-ospf permit 1 (建立ripospf 区域的route-map)
R2(config-route-map)#match ip address 1(匹配访问控制列表1)
R2(config)#router ospf 1
R2(config-router)#redistribute rip route-map rip-ospf metric 200 subnets(引用route-map对重分发的路由进行过滤)
4、现在再看一下 R1上的路由表:
R1#sho ip route
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
 
     172.168.0.0/24 is subnetted, 4 subnets
C       172.168.0.0 is directly connected, Loopback0
C       172.168.1.0 is directly connected, Loopback0
C       172.168.2.0 is directly connected, Loopback0
C       172.168.3.0 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.255.0 is directly connected, Serial1/1
O E2 192.168.255.0/24 [110/200] via 172.16.255.2, 00:00:11, Serial1/1
O E2 192.168.0.0/24 [110/200] via 172.16.255.2, 00:00:10, Serial1/1
O E2 192.168.1.0/24 [110/200] via 172.16.255.2, 00:00:10, Serial1/1 (现在只学到了3条)
四、针对 OSPF区域的配置步骤
1、上一个步骤已经看到了 R3的路由表,全部路由都学到了,那么我现在还是要在 R2上建立 access-list,并在 route-map上调用,然后再引用 route-map对重分发的路由进行过滤。
R2(config)#access-list 2 deny 172.168.0.0 0.0.0.255
R2(config)#access-list 2 deny 172.168.1.0 0.0.0.255
R2(config)#access-list 2 permit any
R2(config)#route-map ospf-rip permit 2 (建立ospfrip 区域的route-map)
R2(config-route-map)#match ip address 2(匹配访问控制列表2)
R2(config)#router rip
R2(config-router)#redistribute ospf 1 route-map ospf-rip metric 10 ( 引用route-map对重分发的路由进行过滤)
2、再来看一下 R3的路由表:
R3#sh ip route
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
 
     172.168.0.0/24 is subnetted, 2 subnets
R       172.168.2.0 [120/10] via 192.168.255.2, 00:00:11, Serial1/0
R       172.168.3.0 [120/10] via 192.168.255.2, 00:00:11, Serial1/0
     172.16.0.0/24 is subnetted, 1 subnets
R       172.16.255.0 [120/10] via 192.168.255.2, 00:00:11, 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, Loopback0
C    192.168.2.0/24 is directly connected, Loopback0
C    192.168.3.0/24 is directly connected, Loopback0
3、呵呵,现在变成只能学到三条 RIP那边过来的路由,开始我很郁闷啊,这一步我一直 clear ip route * ,但是却一直还是 5R,检查配置实在找不出原因,想想,我后来只有把配置导出来,然后重启模拟器,再把配置导进去。后来就只能学到这三条了,果然真是模拟器的原因。纠结啊。现在我们用 route-map也能达到目的,或者用 distribute-list 对路由更新筛选目的。不过用 distribute-list步骤要少一点。不过没关系。多一个方法,多一条路。现实生活和工作中何尝不是呢?懂比不懂要好。
 
 本文转自wxs-163 51CTO博客,原文链接:
 http://blog.51cto.com/supercisco/255546
相关文章
通过map解决导航路由递归问题
通过map解决导航路由递归问题
327 0
通过map解决导航路由递归问题
|
数据安全/隐私保护 网络架构 网络虚拟化
|
10月前
|
安全 Java 数据库连接
让我们讲解一下 Map 集合遍历的方式
我是小假 期待与你的下一次相遇 ~
361 43
|
存储 前端开发 API
ES6的Set和Map你都知道吗?一文了解集合和字典在前端中的应用
该文章详细介绍了ES6中Set和Map数据结构的特性和使用方法,并探讨了它们在前端开发中的具体应用,包括如何利用这些数据结构来解决常见的编程问题。
ES6的Set和Map你都知道吗?一文了解集合和字典在前端中的应用
|
存储 安全 Java
java集合框架复习----(4)Map、List、set
这篇文章是Java集合框架的复习总结,重点介绍了Map集合的特点和HashMap的使用,以及Collections工具类的使用示例,同时回顾了List、Set和Map集合的概念和特点,以及Collection工具类的作用。
java集合框架复习----(4)Map、List、set
|
Go 定位技术 索引
Go 语言Map(集合) | 19
Go 语言Map(集合) | 19