实验拓扑:
IP 配置
R1:
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 1.0.0.1 24
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 13.0.0.1 24
R2:
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 12.0.0.2 24
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip address 14.0.0.1 24
R3:
[R3]int LoopBack 0
[R3-LoopBack0]ip address 13.0.0.2 24
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]ip address 15.0.0.1 24
R4:
[R4]int LoopBack 0
[R4-LoopBack0]ip address 4.0.0.1 24
[R4]interface g0/0/1
[R4-GigabitEthernet0/0/1]ip address 15.0.0.2 24
RIP配置、OSPF配置以及重发布:
R1:
[R1]rip 1
[R1-rip-1]version 2
[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 2.0.0.0
[r2-rip-1]network 12.0.0.0
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area0
[R2-ospf-1-area-0.0.0.0]network 14.0.0.0 0.0.0.255
R3:
[r3]rip 1
[r3-rip-1]version 2
[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.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 15.0.0.0 0.0.0.255
R4:
[4]ospf 1 router-id 4.4.4.4
[4-ospf-1]area 0
[4-ospf-1-area-0.0.0.0]network 14.0.0.0 0.0.0.255
[4-ospf-1-area-0.0.0.0]network 15.0.0.0 0.0.0.255
[4-ospf-1-area-0.0.0.0]network 4.0.0.0 0.0.0.255
在这里先查看R2 R3的路由表(display ip routing-table)
R2:
R3 :
双向重发布
R2
[R2-rip-1]import-route os
[R2-rip-1]import-route ospf 1
[R2-ospf-1]import-route rip 1
r3
R3]ospf 1
[R3-ospf-1]im
[R3-ospf-1]import-route rip
[R3-ospf-1]import-route rip 1
[R3]rip
[R3-rip-1]im
[R3-rip-1]import-route os
[R3-rip-1]import-route ospf 1
紧接着我们调整选路:
R2:
[R2]ip ip-prefix yy permit 15.0.0.0 2
[R2]ip ip-prefix yy permit 3.0.0.0 32
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]rip metricout ip-prefix yy 10
[R2-GigabitEthernet0/0/0]ip ip-prefix dd permit 12.0.0.0 24
[R2]ip ip-prefix dd permit 2.0.0.0 24
[R2]route-policy ddd permit node 10
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix dd
[R2-route-policy]apply cost-type type-1
[R2-route-policy]q
[R2]route-policy ddd permit node 20
Info: New Sequence of this List.
[R2-route-policy]q
[R2]ospf 1
[R2-ospf-1]import-route rip route-policy ddd
R3:
[R3]ip ip
[R3]ip ip-prefix y p
[R3]ip ip-prefix y permit 14.0.0.0 24
[R3]int
[R3]interface g0/0/1
[R3-GigabitEthernet0/0/1]rip m
[R3-GigabitEthernet0/0/1]rip metricin
[R3-GigabitEthernet0/0/1]rip metricout ip
[R3-GigabitEthernet0/0/1]rip metricout ip-prefix y 10
[R3]ip ip-prefix s permit 13.0.0.0 24
[R3]route-policy ss permit node 10
Info: New Sequence of this List.
[R3-route-policy]if-match ip-prefix s
[R3-route-policy]apply cost-type type-1
[R3]route-policy ss permit node 20
Info: New Sequence of this List.
[R3]ospf 1
[R3-ospf-1]import-route rip route-policy ss