第一步:配置IP地址
R1
<Huawei>sys
Enter system view, return user view with Ctrl+Z..
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
Jul 29 2023 13:18:17-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 41.1.1.1 24
Jul 29 2023 13:18:46-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 10.1.1.1 24
[R1-LoopBack0]
R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 23.1.1.2 24
[R2-GigabitEthernet0/0/1]int l0
[R2-LoopBack0]ip address 20.1.1.1 24
R3
[R3]int l0
[R3-LoopBack0]ip address 30.1.1.1 24
[R3-LoopBack0]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 23.1.1.3 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 34.1.1.3 24
R4
[R4]int l0
[R4-LoopBack0]ip address 40.1.1.1 24
[R4-LoopBack0]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 34.1.1.4 24
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip address 41.1.1.4 24
第二步:配置rip和ospf协议
R1
[R1]rip 1
[R1-rip-1]version 2
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 41.0.0.0
[R1-rip-1]network 10.0.0.0
R2
[R2]rip 1
[R2-rip-1]network 12.0.0.0
[R2-rip-1]network 20.0.0.0
[R2-rip-1]q
[R2]ospf 1 router-id 1.1.1.1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]ne
[R2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
R3
[R3]ospf 1 router-id 2.2.2.2
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 34.1.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 30.1.1.0 0.0.0.255
R4
[R4]rip 1
[R4-rip-1]version 2
[R4-rip-1]network 41.0.0.0
[R4-rip-1]q
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[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 40.1.1.0 0.0.0.255
第三步:双点双向重发布
双点指的是两台ASBR路由器,双向指的是ASBR两边路由协议互相进行重发布
R2
[R2]rip 1
[R2-rip-1]import-route ospf 1
[R2-rip-1]q
[R2]ospf 1 router-id 1.1.1.1
[R2-ospf-1]import-route rip 1
R4
[R4]rip 1
[R4-rip-1]import-route ospf 1
[R4-rip-1]q
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]import-route rip 1
第四步:查看路由表
R3
R1
第五步:解决选路不佳
R1和R3设备在访问对端环回地址时为等负载均衡,但是R1访问23.1.1.0网段很明显选上边的路更合适,R1访问40.1.1.0网段很明显选下边的路更合适,已经不适合进行等负载均衡,故需要进行干涉选路 。
[R3-LoopBack0]ospf network-type broadcast
[R4-LoopBack0]ospf network-type broadcast
R2 上的配置
#解决40.1.1.0和34.1.1.0网段
[R2]ip ip-prefix 1 permit 40.1.1.0 24
[R2]route-policy 1 permit node 10
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix 1
[R2-route-policy]apply cost + 10
[R2-route-policy]q
[R2]route-policy 1 permit node 20
Info: New Sequence of this List.
[R2-route-policy]q
[R2]rip 1
[R2-rip-1]import-route ospf 1 route-policy 1
[R2-rip-1]q
[R2]ip ip-prefix 2 permit 34.1.1.0 24
[R2]route-policy 1 permit node 15
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix 2
[R2-route-policy]apply cost + 10#解决12.1.1.0和20.1.1.0网段
[R2-ospf-1]import-route rip 1 type 1
R4上的配置
解决23.1.1.0路段
[R4]ip ip-prefix 1 permit 23.1.1.0 24
[R4]route-policy 1 permit node 10
Info: New Sequence of this List.
[R4-route-policy]if-match ip-prefix 1
[R4-route-policy]apply cost + 10
[R4-route-policy]q
[R4]route-policy 1 permit node 20
Info: New Sequence of this List.
[R4-route-policy]q
[R4]rip 1
[R4-rip-1]import-route ospf 1 route-policy 1#解决41.1.1.0路段
[R4]ip ip-prefix 14 permit 41.1.1.0 24
[R4]route-policy 14 permit node 10
Info: New Sequence of this List.
[R4-route-policy]if-match ip-prefix 14
[R4-route-policy]apply cost-type type-1
[R4-route-policy]apply cost - 10
[R4-route-policy]q
[R4]route-policy 14 permit node 20
Info: New Sequence of this List.
[R4-route-policy]q
[R4]ospf 1
[R4-ospf-1]import-route rip 1 route-policy 14