配置IP:
R1:
[r1-LoopBack0]ip address 1.1.1.1 24
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[r1-GigabitEthernet0/0/1]ip address 13.1.1.1 24
R2:
[r2-LoopBack0]ip address 2.2.2.2 24
[r2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[r2-GigabitEthernet0/0/1]ip address 24.1.1.1 24
R3:
[r3-LoopBack0]ip address 3.3.3.3 24
[r3-GigabitEthernet0/0/0]ip address 13.1.1.2 24
[r3-GigabitEthernet0/0/1]ip address 34.1.1.1 24
R4:
[r4-LoopBack0]ip address 4.4.4.4 24
[r4-GigabitEthernet0/0/0]ip address 24.1.1.2 24
[r4-GigabitEthernet0/0/1]ip address 34.1.1.2 24
[r4-GigabitEthernet0/0/2]ip address 45.1.1.1 24
R5:
[r5-LoopBack0]ip address 5.5.5.5 24
[r5-GigabitEthernet0/0/0]ip address 45.1.1.2 24
[r5-GigabitEthernet0/0/1]ip address 56.1.1.1 24
R6:
[r6-LoopBack0]ip address 6.6.6.6 24
[r6-GigabitEthernet0/0/0]ip address 56.1.1.2 24
[r6-GigabitEthernet0/0/1]ip address 67.1.1.1 24
R7:
[r7-LoopBack0]ip address 7.7.7.7 24
[r7-GigabitEthernet0/0/0]ip address 67.1.1.2 24
协议配置:
R1:
[r1-rip-1]network 1.0.0.0
[r1-rip-1]network 12.0.0.0
[r1-rip-1]network 13.0.0.0
R2:
[r2]rip 1
[r2-rip-1]version 2
[r2-rip-1]network 12.0.0.0
[r2-rip-1]network 2.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.1 0.0.0.0
R3:
[r3]rip 1
[r3-rip-1]version 2
[r3-rip-1]network 34.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 34.1.1.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
R4:
[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.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 45.1.1.1 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
R5:
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 45.1.1.2 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 56.1.1.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
R6:
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 56.1.1.2 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 67.1.1.1 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
R7:
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 67.1.1.2 0.0.0.0
[r7]rip 1
[r7-rip-1]version 2
[r7-rip-1]network 7.0.0.0
重发布路由:
R2:[r2-ospf-1]import-route rip 1
[r2-rip-1]import-route ospf 1
R3:[r3-ospf-1]import-route rip 1
[r3-rip-1]import-route ospf 1
R7:[r7-ospf-1]import-route rip 1
路由策略:
R2:
[r3]ip ip-prefix qq index 10 permit 7.7.7.0 24
[r3]route-policy qq permit node 10
[r3-route-policy]if-match ip-prefix qq
[r3-route-policy]apply preference 151
[r3]rip 1
[r3-rip-1]preference route-policy qq
[r2]ip ip-prefix a permit 7.7.7.0 24
[r2]route-policy qq permit node 10
[r2-route-policy]if-match ip-prefix a
[r2-route-policy]apply preference 151
[r2]rip 1
[r2-rip-1]preference route-policy qq
[r3-LoopBack0]ip address 3.3.3.3 32
[r2]ip ip-prefix a permit 34.1.1.0 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix a 2
[r3]ip ip-prefix b permit 24.1.1.0 24
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]rip metricout ip-prefix b 2
[r2]ip ip-prefix c permit 12.1.1.0 24
[r2]ip ip-prefix c permit 2.2.2.0 24
[r2]route-policy a permit node 10
[r2-route-policy]if-match ip-prefix c
[r2-route-policy]apply cost-type type-1
[r2]route-policy c permit node 20
[r2-ospf-1]import-route rip route-policy a
[r3]ip ip-prefix c permit 13.1.1.0 24
[r3]route-policy c permit node 10
[r3-route-policy]if-match ip-prefix c
[r3-route-policy]apply cost-type type-1
[r3]route-policy cc permit node 20
[r3-ospf-1]import-route rip route-policy c
[r2]ip ip-prefix b permit 3.3.3.3 32
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix b 3
实验结果: