做到才是得到!光说不练假把式!加油

 

 

路由映射的学习_路由映射

拓扑图如上,实现RIP重分布到OSPF,并控制一些路由不能重分布到OSPF中

基本配置如下:

R1

 

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#int se0/0

R1(config-if)#ip ad 12.1.1.1 255.0.0.0

R1(config-if)#no sh

R1(config-if)#int lo 0

R1(config-if)#ip ad 192.168.1.1 255.255.255.0

R1(config-if)#int lo 1

R1(config-if)#ip ad 192.168.2.1 255.255.255.0

R1(config-if)#int lo 2

R1(config-if)#ip ad 192.168.3.1 255.255.255.0

R1(config-if)#router rip

R1(config-router)#ve 2

R1(config-router)#no au

R1(config-router)#net 12.0.0.0

R1(config-router)#net 192.168.1.0

R1(config-router)#net 192.168.2.0

R1(config-router)#net 192.168.3.0

R2

 

R2(config)#int se0/0

R2(config-if)#ip ad 12.1.1.2 255.0.0.0

R2(config-if)#no sh

R2(config-if)#ip ad 23.1.1.1 255.0.0.0

R2(config-if)#no sh

R2(config-if)#router rip

R2(config-router)#ve 2

R2(config-router)#no au

R2(config-router)#net 12.0.0.0

R2(config-router)#router os 1

R2(config-router)#net 23.0.0.0 0.255.255.255 area 0

R2(config-router)#redistribute rip subnets

 

R3

 

R3(config)#int se0/0

R3(config-if)#ip ad 23.1.1.2 255.0.0.0

R3(config-if)#no sh

R3(config-if)#router os 1

R3(config-router)#net 23.0.0.0 0.255.255.255 area 0

OK 基本配置完成,下面看下R3的路由表

 

R3(config-router)#do show 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

 

C    23.0.0.0/8 is directly connected, Serial0/0

O E2 12.0.0.0/8 [110/20] via 23.1.1.1, 00:00:00, Serial0/0

O E2 192.168.1.0/24 [110/20] via 23.1.1.1, 00:00:00, Serial0/0

O E2 192.168.2.0/24 [110/20] via 23.1.1.1, 00:00:00, Serial0/0

O E2 192.168.3.0/24 [110/20] via 23.1.1.1, 00:00:00, Serial0/0

 

可以看到已经重分布成功!

接下来就看这次实验的重点了!

现在要实现不让

192.168.1.0/24 192.168.2.0/24

重分布到OSPF中!

 

方法1:

R2:

R2(config)#access-list 1 deny 192.168.1.0 0.0.0.255

R2(config)#access-list 1 deny 192.168.2.0 0.0.0.255

R2(config)#access-list 1 permit any//创建访问列表,拒绝完了注意最后要加允许命令!

R2(config)#route-map kkk permit 10 //创建命为kkk的路由映射 ,

如果这里配置成route-map kkk deny 10 那么OSPF将不会学到任何重分布来的路由!因为是拒绝所有匹配列表1,在permit any中就包含了其他路由,所以就全部给拒绝了!这里要注意一下

R2(config-route-map)#mat ip ad 1 // 匹配列表1

R2(config)#router os 1

 

R2(config-router)#no redistribute rip subnets //删除之前的重分布

R2(config-router)#redistribute rip subnets route-map kkk

OK配置完成,再看看R3的路由表:

 

R3(config-router)#do show 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

 

C    23.0.0.0/8 is directly connected, Serial0/0

O E2 12.0.0.0/8 [110/20] via 23.1.1.1, 00:05:20, Serial0/0

O E2 192.168.3.0/24 [110/20] via 23.1.1.1, 00:05:20, Serial0/0

可以看到实验成功了!

 

 

方法2:首先删除之前的访问列表和路由映射,重分布就不用删了

 

R2(config)#access-list 1 permit 12.0.0.0 0.255.255.255

R2(config)#access-list 1 permit 192.168.3.0 0.0.0.255 

R2(config)#route-map kkk permit 10

R2(config-route-map)#mat ip ad 1

 

R3(config-router)#do show 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

 

C    23.0.0.0/8 is directly connected, Serial0/0

O E2 12.0.0.0/8 [110/20] via 23.1.1.1, 00:00:14, Serial0/0

O E2 192.168.3.0/24 [110/20] via 23.1.1.1, 00:00:14, Serial0/0

实验成功!

 

 

方法三:用打标签的方法,首先删除之前的访问列表和路由映射,重分布就不用删了

 

R2(config)#access-list 1 permit 192.168.1.0 0.0.0.255

R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255

R2(config)#route-map kkk permit 10

R2(config-route-map)#mat ip ad 1

R2(config-route-map)#set tag 1

R2(config-route-map)#route-map kkk permit 20 //因为在每个路由映射的结尾都隐含了一个拒绝操作,如果不加这条命令,要被允许的路由也不能进入OSPF!

上面的配置相当于在服务器端R2为要过滤的路由打上标记1

 

R3(config)#route-map aaa deny 10

R3(config-route-map)#match tag 1

这里就相当于在客户端进行匹配操作,如果有被打标记1的路由就阻止!

R3(config-route-map)#route-map aaa permit 20

R3(config-route-map)#router os 1

R3(config-router)#distribute-list route-map aaa in 把路由映射运用到进接口的放向!

 

R3(config-router)#do show 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

 

C    23.0.0.0/8 is directly connected, Serial0/0

O E2 12.0.0.0/8 [110/20] via 23.1.1.1, 00:00:05, Serial0/0

O E2 192.168.3.0/24 [110/20] via 23.1.1.1, 00:00:05, Serial0/0

成功!