第一步,配置各路由器的接口地址和环回接口地址
[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[R1-GigabitEthernet0/0/1]ip address 13.1.1.1 24
[R1-LoopBack0]ip address 1.1.1.1 24
[R1-LoopBack1]ip address 172.16.1.1 24
[R1-LoopBack2]ip address 172.16.2.1 24
[R1-LoopBack3]ip address 172.16.3.1 24
[R1-LoopBack4]ip address 172.16.4.1 24
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[R2-GigabitEthernet0/0/1]ip address 24.1.1.2 24
[R2-LoopBack0]ip address 2.2.2.2 24
[R3-GigabitEthernet0/0/0]ip address 13.1.1.3 24
[R3-GigabitEthernet0/0/1]ip address 34.1.1.3 24
[R3-LoopBack0]ip address 3.3.3.3 24
[R4-GigabitEthernet0/0/0]ip address 24.1.1.4 24
[R4-GigabitEthernet0/0/1]ip address 34.1.1.4 24
[R4-LoopBack0]ip address 4.4.4.4 24
第二步,RIP和OSPF区域宣告
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 13.0.0.0
[R1-rip-1]network 1.0.0.0
[R1-rip-1]network 172.16.0.0
[R2-rip-1]network 2.0.0.0
[R2-rip-1]network 12.0.0.0
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 24.1.1.0 0.0.0.255
[R3-rip-1]network 13.0.0.0
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 24.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 4.4.4.0 0.0.0.255
第三步,重发步
[R2-ospf-1]import-route rip 1
[R2-rip-1]import-route ospf 1
[R3-ospf-1]import-route rip 1
[R3-rip-1]import-route ospf 1
第四步,启动路由策略
[R3]interface LoopBack 0
[R3-LoopBack0]ospf network-type broadcast
[R2]ip ip-prefix 1 permit 172.16.1.0 24
[R2]ip ip-prefix 2 permit 172.16.2.0 24
[R2]ip ip-prefix 3 permit 172.16.3.0 24
[R2]ip ip-prefix 4 permit 172.16.4.0 24
[R2]route-policy 1 deny node 10
[R2-route-policy]if-match ip-prefix 1
[R2]route-policy 1 permit node 20
[R2-route-policy]if-match ip-prefix 2
[R2-route-policy]apply cost-type type-1
[R2]route-policy 1 permit node 30
[R2-route-policy]if-match ip-prefix 3
[R2-route-policy]apply cost 6
[R2]route-policy 1 permit node 40
[R2-route-policy]if-match ip-prefix 4
[R2-route-policy]apply cost 9
[R2-route-policy]apply cost-type type-1
[R2]route-policy 1 permit node 50
[R2-ospf-1]import-route rip 1 route-policy 1
R3上同理
[R3]ip ip-prefix 1 index 10 permit 172.16.1.0 24
[R3]ip ip-prefix 2 index 10 permit 172.16.2.0 24
[R3]ip ip-prefix 3 index 10 permit 172.16.3.0 24
[R3]ip ip-prefix 4 index 10 permit 172.16.4.0 24
[R3]route-policy 1 deny node 10
[R3-route-policy] if-match ip-prefix 1
[R3-route-policy]route-policy 1 permit node 20
[R3-route-policy] if-match ip-prefix 2
[R3-route-policy] apply cost-type type-1
[R3-route-policy]route-policy 1 permit node 30
[R3-route-policy] if-match ip-prefix 3
[R3-route-policy] apply cost 6
[R3-route-policy]route-policy 1 permit node 40
[R3-route-policy] if-match ip-prefix 4
[R3-route-policy] apply cost 9
[R3-route-policy] apply cost-type type-1
[R3-route-policy]route-policy 1 permit node 50
[R3-ospf-1]import-route rip 1 route-policy 1
[R2]ip ip-prefix xixi permit 2.2.2.0 24
[R2]route-policy 1 permit node 15
[R2-route-policy]if-match ip-prefix xixi
[R2-route-policy]apply cost-type type-1
[R2]ip ip-prefix 12 permit 12.1.1.0 24
[R2]route-policy 1 permit node 25
[R2-route-policy]if-match ip-prefix 12
[R2-route-policy]apply cost-type type-1
[R3]ip ip-prefix 14 permit 13.1.1.0 24
[R3]route-policy 1 permit node 15
[R3-route-policy]if-match ip-prefix 14
[R3-route-policy]apply cost-type type-1
[R1]ip ip-prefix 4 permit 3.3.3.0 24
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]rip metricin ip-prefix 4 2
[R1]ip ip-prefix 24 permit 24.1.1.0 24
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]rip metricin ip-prefix 23 2
实验成功!