acl basic 2000
rule 5 permit source 192.168.20.0 0.0.0.255
#
acl basic 2100
rule 5 permit source 192.168.40.0 0.0.0.255
#
route-policy 20-cost permit node 5
if-match ip address acl 2000
apply cost 20
#
route-policy 20-cost permit node 20
#
route-policy 40-cost permit node 5
if-match ip address acl 2100
apply cost 40
#
route-policy 40-cost permit node 10
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 10.0.12.2 0.0.0.0
area 0.0.0.1
network 10.0.24.2 0.0.0.0
filter route-policy 40-cost export
filter route-policy 20-cost import
#
2、R3上的关键配置
acl basic 2000
rule 5 permit source 192.168.10.0 0.0.0.255
#
acl basic 2100
rule 5 permit source 192.168.30.0 0.0.0.255
#
route-policy 10-cost permit node 5
if-match ip address acl 2000
apply cost 30
#
route-policy 10-cost permit node 20
#
route-policy 30-cost permit node 5
if-match ip address acl 2100
apply cost 50
#
route-policy 30-cost permit node 10
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 10.0.13.3 0.0.0.0
area 0.0.0.1
network 10.0.34.3 0.0.0.0
filter route-policy 30-cost export
filter route-policy 10-cost import
三、效果图
1、PC 7去tracert PC
2、PC 8去tracert PC 6
3、R3的上行接口GE0/0故障后,查看PC8访问PC 6路径