R4#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.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial1/0
10.0.0.0/30 is subnetted, 2 subnets
R 10.1.1.0 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R 10.1.1.4 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R 192.168.0.0/24 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R 192.168.1.0/24 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R 192.168.2.0/24 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R 192.168.3.0/24 [120/10] via 172.16.1.1, 00:00:14, Serial1/0
R4# |
R2(config)#access-list 1 permit 192.168.0.0 0.0.0.255(设定ACL,为我们标记服务,在R2上可不过滤)
R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255
R2(config)#route-map filter_tag permit 10(许可名为filter_tag的route-map 序号为10的名称)
R2(config-route-map)#match ip add 1 (匹配ACL 1)
R2(config-route-map)#set tag 1 (设置一个tag ,分配标记为1)
R2(config-route-map)#exit
R2(config)#route-map filter_tag permit 20(切记一定要加这一条,不然的话,将会如下图所示。意思是其它的没打上标记的路由都无条件转发出去。20为我们定义的route-map的序列号)
R2(config-route-map)#router ospf 1
R2(config-router)#redistribute eigrp 10 subnets route-map filter_tag(重分发时调用route-map,同时filter_tag标记也嵌入进去了) |
R4#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.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial1/0
10.0.0.0/30 is subnetted, 1 subnets
R 10.1.1.4 [120/10] via 172.16.1.1, 00:00:02, Serial1/0
R 192.168.0.0/24 [120/10] via 172.16.1.1, 00:00:02, Serial1/0
R 192.168.2.0/24 [120/10] via 172.16.1.1, 00:00:02, Serial1/0
说明:在R2上加上route-map filter_tag permit 20 意思是: 其它没有打上标记的路由都无条件转发,这样我们就形成了一个除了192.168.0.0/24和192.168.2.0/24两条路由过滤外,其它没标记的路由都转发。R3上也要加上一条这种命令,不然也不会转发没有打上标记的其它路由。 |
R3(config)#route-map match_tag deny 10 (在R3建立一个名为macth_tag 的route-map)
R3(config-route-map)#match tag 1 (用来匹配标记 1,达到拒绝打了标记tag 1的路由)
R2(config-route-map)#exit
R3(config-route-map)#route-map match_tag permit 20(也一定要加,不然不会转发其它没标记的路由)
R3(config-route-map)#router rip(因为方向是往右的,也就是把ospf 重分发进rip,所以是进入rip)
R3(config-router)#redistribute ospf 1 metric 10 route-map match_tag(重分发时匹配刚建立的标记) |
R4#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.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial1/0
10.0.0.0/30 is subnetted, 2 subnets
R 10.1.1.0 [120/10] via 172.16.1.1, 00:00:01, Serial1/0
R 10.1.1.4 [120/10] via 172.16.1.1, 00:00:01, Serial1/0
R 192.168.1.0/24 [120/10] via 172.16.1.1, 00:00:01, Serial1/0
R 192.168.3.0/24 [120/10] via 172.16.1.1, 00:00:01, Serial1/0 |