路由策略小案例_第1张图片

路由策略和策略路由不一样,策略路由是先执行策略后查看路由;路由策略是先执行路由再查看策略。

R1:

conf ter

int loo 0

ip add 10.1.1.1255.255.255.0

no shu

int loo 1

ip add 10.1.2.1255.255.255.0

no shu

int loo 2

ip add 10.1.3.1255.255.255.0

no shu

ex

int f1/0

ip add 10.1.4.1255.255.255.0

no shu

exit

router rip

ver 2

no au

net 10.0.0.0   //只宣告主类网

exit


R2:

conf ter

int f1/0

ip add 10.1.4.2255.255.255.0

no shu

int f1/1

ip add 10.1.5.1255.255.255.0

no shu

exit

router ospf 100

net 10.1.5.00.0.0.255 ar 0

exit

router rip

ver 2

no au

passive-interface f1/1  //设置接口为被动接口,使其只接受外部rip宣告,自己不宣告rip

net 10.0.0.0

exit


R3:

conf ter

int f1/0

ip add 10.1.5.2255.255.255.0

no shu

exit

int loo 0

ip add 10.1.6.1255.255.255.0

no shu

int loo 1

ip add 10.1.7.1255.255.255.0

no shu

int loo 2

ip add 10.1.8.1255.255.255.0

no shu

exit

router ospf 100

net 10.1.5.00.0.0.255 ar 0

net 10.1.6.00.0.0.255 ar 0

net 10.1.7.00.0.0.255 ar 0

net 10.1.8.00.0.0.255 ar 0

exit

R2:

access-list 1 permit 10.1.3.0 0.0.0.255 //ACL过滤需要处理的网段

route-map test01 deny 10

match ip address 1//执行"拒绝ACL 1 的网段"

exit

route-map test01permit 15

exit

router os 100//打开目标协议

redistribute rip subnets route-map test01//rip重分布到ospf

exit

access-list 2 permit 10.1.7.0 0.0.0.255   //ACL过滤需要处理的网段

route-map test02permit 10

match ip address 2

set metric 8//执行"ACL2的网段metric 8"

exit

route-map test02permit 15

set metric 5//执行"其他网段metric 5"

exit

router rip//打开目标协议

redistribute ospf 100 rpute-map test02//ospf重分布到rip

exit

测试:

R1

R1#show ip ro

Codes: L - local, 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 - OSPFexternal type 2

      i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2

      ia - IS-IS inter area, * - candidatedefault, U - per-user static route

      o - ODR, P - periodic downloaded staticroute, + - replicated route


Gateway of lastresort is not set


     10.0.0.0/8 is variably subnetted, 12subnets, 2 masks

C        10.1.1.0/24 is directly connected,Loopback0

L        10.1.1.1/32 is directly connected,Loopback0

C        10.1.2.0/24 is directly connected,Loopback1

L        10.1.2.1/32 is directly connected,Loopback1

C        10.1.3.0/24 is directly connected,Loopback2

L        10.1.3.1/32 is directly connected,Loopback2

C        10.1.4.0/24 is directly connected,FastEthernet1/0

L        10.1.4.1/32 is directly connected,FastEthernet1/0

R        10.1.5.0/24 [120/1] via 10.1.4.2,00:00:27, FastEthernet1/0

R        10.1.6.1/32 [120/5] via 10.1.4.2,00:00:27, FastEthernet1/0

R        10.1.7.1/32 [120/8] via 10.1.4.2,00:00:27, FastEthernet1/0

R        10.1.8.1/32 [120/5] via 10.1.4.2,00:00:27, FastEthernet1/0

R3:

R3#show ip ro

Codes: L - local, 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 - OSPFexternal type 2

      i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2

      ia - IS-IS inter area, * - candidatedefault, U - per-user static route

      o - ODR, P - periodic downloaded staticroute, + - replicated route


Gateway of lastresort is not set


     10.0.0.0/8 is variably subnetted, 11subnets, 2 masks

O E2     10.1.1.0/24 [110/20] via 10.1.5.1,00:00:44, FastEthernet1/0

O E2     10.1.2.0/24 [110/20] via 10.1.5.1,00:00:44, FastEthernet1/0

O E2     10.1.4.0/24 [110/20] via 10.1.5.1,00:00:44, FastEthernet1/0

C        10.1.5.0/24 is directly connected,FastEthernet1/0

L        10.1.5.2/32 is directly connected,FastEthernet1/0

C        10.1.6.0/24 is directly connected,Loopback0

L        10.1.6.1/32 is directly connected,Loopback0

C        10.1.7.0/24 is directly connected,Loopback1

L        10.1.7.1/32 is directly connected,Loopback1

C        10.1.8.0/24 is directly connected,Loopback2

L        10.1.8.1/32 is directly connected,Loopback2