实验拓扑图
实验过程
1. R1的预配置
Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-lookup Router(config)#line console 0 Router(config-line)#no exec-timeout Router(config-line)#loggin syn Router(config-line)#exit Router(config)#host R1 R1(config)#int lo0 R1(config-if)#ip add 192.168.0.1 255.255.255.0 R1(config-if)#ip add 192.168.1.1 255.255.255.0 second R1(config-if)#ip add 192.168.2.1 255.255.255.0 second R1(config-if)#ip add 192.168.3.1 255.255.255.0 second R1(config-if)#exit R1(config)#int s0/0 R1(config-if)#no shut R1(config-if)#ip add 10.1.1.1 255.255.255.252 R1(config-if)#exit |
2. R2的预配置
Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-lookup Router(config)#line console 0 Router(config-line)#no exec-timeout Router(config-line)#loggin syn Router(config-line)#exit Router(config)#host R2 R2(config)#int s0/0 R2(config-if)#no shut R2(config-if)#ip add 10.1.1.2 255.255.255.252 R2(config-if)#exit R2(config)#int s0/1 R2(config-if)#no shut R2(config-if)#ip add 10.1.1.5 255.255.255.252 R2(config-if)#exit |
3. R3的预配置
Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-lookup Router(config)#line console 0 Router(config-line)#no exec-timeout Router(config-line)#loggin syn Router(config-line)#exit Router(config)#host R3 R3(config)#int s0/1 R3(config-if)#no shut R3(config-if)#ip add 10.1.1.6 255.255.255.252 R3(config-if)#exit R3(config)#int s0/2 R3(config-if)#no shut R3(config-if)#ip add 172.16.1.1 255.255.255.0 R3(config-if)#exit |
4. R4的预配置
Router>en Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#no ip domain-lookup Router(config)#line console 0 Router(config-line)#no exec-timeout Router(config-line)#loggin syn Router(config-line)#exit Router(config)#host R4 R4(config)#int s0/2 R4(config-if)#no shut R4(config-if)#ip add 172.16.1.2 255.255.255.0 R4(config-if)#exit |
5. R1的eigrp配置
R1(config)#router eigrp 100 R1(config-router)#no auto R1(config-router)#net 192.168.0.1 R1(config-router)#net 192.168.1.1 R1(config-router)#net 192.168.2.1 R1(config-router)#net 192.168.3.1 R1(config-router)#net 10.1.1.1 R1(config-router)#exit |
6. R2的eigrp和ospf配置
R2(config)#router eigrp 100 R2(config-router)#no auto R2(config-router)#net 10.1.1.2 R2(config-router)#exit R2(config)#router ospf 1 R2(config-router)#net 10.1.1.5 0.0.0.0 area 0 R2(config-router)#exit |
7. R3的ospf和rip配置
R3(config)#router ospf 1 R3(config-router)#net 10.1.1.6 0.0.0.0 area 0 R3(config-router)#exit R3(config)#router rip R3(config-router)#version 2 R3(config-router)#no auto R3(config-router)#net 172.16.1.0 R3(config-router)#end |
8. R4的rip配置
R4(config)#router rip R4(config-router)#version 2 R4(config-router)#no auto R4(config-router)#net 172.16.1.0 R4(config-router)#end |
9. R2和R3重分布的配置
R2(config)#router eigrp 100 R2(config-router)#redistribute ospf 1 metric 10000 100 255 1 1500 //ospf重发布进eigrp R2(config-router)#exit R2(config)#router ospf 1 R2(config-router)#redistribute eigrp 100 subnets //eigrp重发布进ospf R2(config-router)#exit |
R3(config)#router ospf 1 R3(config-router)#redistribute rip metric 100 subnets //rip重发布进ospf R3(config-router)#exit R3(config)#router rip R3(config-router)#redistribute ospf 1 metric 10 //ospf重发布进rip R3(config-router)#end |
10. 查看R4的路由表
R4#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 172.16.0.0/24 is subnetted, 1 subnets C 172.16.1.0 is directly connected, Serial0/2 10.0.0.0/30 is subnetted, 2 subnets R 10.1.1.0 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 R 10.1.1.4 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 R 192.168.0.0/24 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 R 192.168.1.0/24 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 R 192.168.2.0/24 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 R 192.168.3.0/24 [120/10] via 172.16.1.1, 00:00:19, Serial0/2 |
说明:可以看到R4里面出现了整个网络的路由,这是重发布进去的路由。
11. 我们通过路由标记过滤掉192.168.0.0/24和192.168.1.0/24的路由。
12. 使用路由标记的过滤,分为两个步骤。
一、服务器端路由器配置标记。
二、客户端路由器根据标记进行过滤。
13. 在R2上配置路由标记
R2(config)#access-list 1 permit 192.168.0.0 0.0.0.255 //用ACL抓取需要过滤的路由 R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255 R2(config)#route-map set-tag permit 10 //创建一个route-map R2(config-route-map)#match ip address 1 //匹配刚才的ACL R2(config-route-map)#set tag 1 //进行打标记 R2(config-route-map)#exit R2(config)#route-map set-tag permit 20 //对没有抓取的那部分进行permit操作 R2(config-route-map)#exit R2(config)#router ospf 1 R2(config-router)#redistribute eigrp 100 subnets route-map set-tag //把rip路由重发布进ospf中 R2(config-router)#exit |
R3(config)#route-map match-tag deny 10 //创建一个route-map执行deny操作 R3(config-route-map)#match tag 1 //匹配打标记的路由 R3(config-route-map)#exit R3(config)#route-map match-tag permit 20 //没有打标记的路由执行permit操作 R3(config-route-map)#exit R3(config)#router rip R3(config-router)#redistribute ospf 1 metric 10 route-map match-tag //重发布进rip中 R3(config-router)#exit |
15. 在R2和R3上重启ospf进程(这步是必须的,否则不能看到想要的结果)
R2#clear ip ospf process Reset ALL OSPF processes? [no]: y R3#clear ip ospf process Reset ALL OSPF processes? [no]: y |
16. 查看R4的路由表
R4#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 172.16.0.0/24 is subnetted, 1 subnets C 172.16.1.0 is directly connected, Serial0/2 10.0.0.0/30 is subnetted, 2 subnets R 10.1.1.0 [120/10] via 172.16.1.1, 00:00:07, Serial0/2 R 10.1.1.4 [120/10] via 172.16.1.1, 00:00:11, Serial0/2 R 192.168.1.0/24 [120/10] via 172.16.1.1, 00:00:07, Serial0/2 R 192.168.3.0/24 [120/10] via 172.16.1.1, 00:00:07, Serial0/2 说明:192.168.0.0和192.168.2.0的路由被过滤掉了 |