1.IP的分配 ![](https://i-blog.csdnimg.cn/direct/1eaf5dce6392402c932d65c0f65e891e.png)
2.配置动态路由协议
R1
[r1-rip-1]display this
[V200R003C00]
#
rip 1
version 2
network 1.0.0.0
network 12.0.0.0
network 13.0.0.0
#
return
R2
[r2-rip-1]display this
[V200R003C00]
#
rip 1
version 2
network 12.0.0.0
network 2.0.0.0
#
return
[r2-ospf-1]display this
[V200R003C00]
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 24.0.0.0 0.0.0.255
#
return
R3
[r3-rip-1]display this
[V200R003C00]
#
rip 1
version 2
network 13.0.0.0
#
return
[r3-ospf-1]display this
[V200R003C00]
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 34.0.0.0 0.0.0.255
#
return
R4
[r4-ospf-1]display this
[V200R003C00]
#
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 24.0.0.0 0.0.0.255
network 34.0.0.0 0.0.0.255
#
return
3.重发布
R2
[r2-ospf-1]import-route rip
[r2-rip-1]import-route ospf 1
R3
[r3-rip-1]import-route ospf 1
[r3-ospf-1]import-route rip
其中有两条去往3.3.3.0的网段 ,分别来自R2和R3的重发布,一条来自R2重发布的下一跳为12.0.0.2,另一条为R3重发布的下一跳为13.0.0.2
通过R2的路由信息观察到去往3.3.3.0的网段有两个方向,很可能会造成选路不佳。
解决方法是
[r3]interface LoopBack 0
[r3-LoopBack0]ospf network-type broadcast
4.路由策略
使用路由策略解决负载均衡
R2
[r2]ip ip-prefix a permit 34.0.0.0 24
[r2]ip ip-prefix a permit 3.3.3.0 24
[r2]ip ip-prefix a permit 13.0.0.0 24
[r2]route-policy b permit node 10
Info: New Sequence of this List.
[r2-route-policy]if-match ip-prefix b
[r2-route-policy]apply cost 10
[r2]route-policy b permit node 20
Info: New Sequence of this List.
[r2]ospf
[r2-ospf-1]import-route rip route-policy b
[r2-rip-1]import-route ospf route-policy a
R3
[r3]ip ip-prefix b permit 12.0.0.0 24
[r3]ip ip-prefix b permit 2.2.2.0 24
[r3]route-policy b permit node 10
Info: New Sequence of this List.
[r3-route-policy]if-match ip-prefix b
[r3-route-policy]apply cost 10
[r3]ip ip-prefix a permit 24.0.0.0 24
[r3]route-policy a permit node 10
Info: New Sequence of this List.
[r3-route-policy]if-match ip-prefix a
[r3-route-policy]apply cost 10
[r3]route-policy a permit node 20
Info: New Sequence of this List.
[r3-rip-1]import-route ospf route-policy a
[r3]ospf
[r3-ospf-1]import-route rip route-policy b