步骤一:IP地址的配置
R1
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.12.1 24
[r1-GigabitEthernet0/0/0]q
[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 192.168.13.1 24
[r1-GigabitEthernet0/0/1]q
[r1]int l0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.12.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.13.1 0.0.0.0
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 192.168.12.2 24
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 192.168.24.2 24
[r2]int l0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.12.2 0.0.0.0
[r2-ospf-1]rip 1
[r2-rip-1]version 2
[r2-rip-1]network 192.168.24.0
[r2-rip-1]network 2.0.0.0
R3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 192.168.13.3 24
[r3-GigabitEthernet0/0/0]q
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 192.168.34.3 24
[r3]int l0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]q
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 192.168.13.3 0.0.0.0
[r3-ospf-1]q
[r3]rip 1
[r3-rip-1]version 2
[r3-rip-1]network 3.0.0.0
[r3-rip-1]network 192.168.34.0
R4
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 192.168.24.4 24
[r4-GigabitEthernet0/0/0]q
[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 192.168.34.4 24
[r4]int l0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]q
[r4]rip 1
[r4-rip-1]version 2
[r4-rip-1]network 192.168.24.0
[r4-rip-1]network 192.168.34.0
[r4-rip-1]network 4.0.0.0
1.把R1环回地址重发布到ospf中:
[r1]route-policy huawei permit node 10
Info: New Sequence of this List.
[r1-route-policy]if-match int l0
[r1-route-policy]ospf 1
[r1-ospf-1]import-route direct route-policy huawei
2.ospf学不到rip区域的路由信息,进行双点双向重发布;
R2
[r2-rip-1]import-route ospf 1
[r2]ospf 1
[r2-ospf-1]import-route rip 1
R3
[r3]rip 1
[r3-rip-1]import-route ospf 1
[r3]ospf 1
[r3-ospf-1]import-route rip 1
控制选路:
在R2上将192.168.13.0和3.3.3.0这两条路的度量值加大,在R3上将192.168.12.0这条路的度量值加大即可
R2
[r2]ip ip-prefix aa permit 192.168.13.0 24
[r2]ip ip-prefix aa permit 3.3.3.0 24
[r2]int g0/0/1
[r2-GigabitEthernet0/0/1]rip metricin ip-prefix aa 3
R3
[r3]ip ip-prefix aa permit 192.168.12.0 24
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]rip metricin ip-prefix aa 3
R2上抓192.168.12.0和2.2.2.0的流量,类型改为1(默认为类型2,类型1优于类型2)
R2
[r2]ip ip-prefix jm permit 2.2.2.0 24
[r2]ip ip-prefix jm permit 192.168.12.0 24
[r2]route-policy jm permit node 10
Info: New Sequence of this List.
[r2-route-policy]if-match ip-prefix jm
[r2-route-policy]apply cost-type type-1
[r2-route-policy]q
[r2]ospf 1
[r2-ospf-1]import-route rip 1 route-policy jm
R3
[r3]ip ip-prefix jm permit 192.168.34.0 24
[r3]route-policy jm permit node 10
Info: New Sequence of this List.
[r3-route-policy]if-match ip-prefix jm
[r3-route-policy]apply cost-type type-1
[r3-ospf-1]import-route rip 1 route-policy jm