实验拓扑及要求:
一、进行IP配置:
AR1:
[r1]
#
sysname r1
#
interface Serial4/0/0
link-protocol ppp
ip address 10.1.12.1 255.255.255.0
#
interface GigabitEthernet0/0/0
ip address 10.1.14.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.0
#
rip 1
version 2
network 1.0.0.0
network 10.0.0.0
AR2:
[r2]
#
sysname r2
#
interface Serial4/0/0
link-protocol ppp
ip address 10.1.23.2 255.255.255.0
#
interface Serial4/0/1
link-protocol ppp
ip address 10.1.12.2 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.0
#
ospf 1 router-id 2.2.2.2
import-route rip 1
area 0.0.0.0
network 10.1.23.0 0.0.0.255
#
rip 1
version 2
network 2.0.0.0
network 10.0.0.0
import-route ospf 1
AR3:
[r3]dis current-configuration
[V200R003C00]
#
sysname r3
#
interface Serial4/0/0
link-protocol ppp
ip address 10.1.34.3 255.255.255.0
#
interface Serial4/0/1
link-protocol ppp
ip address 10.1.23.3 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.0
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.0 0.0.0.255
network 10.1.23.0 0.0.0.255
network 10.1.34.0 0.0.0.255
AR4:
[r4]
#
sysname r4
#
interface Serial4/0/1
link-protocol ppp
ip address 10.1.34.4 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 10.1.14.4 255.255.255.0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.0
#
ospf 1 router-id 4.4.4.4
import-route rip 1
area 0.0.0.0
network 10.1.34.0 0.0.0.255
#
rip 1
version 2
network 4.0.0.0
network 10.0.0.0
import-route ospf 1
二、启动动态路由协议及重发布:
[r1]
rip 1
version 2
network 1.0.0.0
network 10.0.0.0
[r2]
#
ospf 1 router-id 2.2.2.2
import-route rip 1
area 0.0.0.0
network 10.1.23.0 0.0.0.255
#
rip 1
version 2
network 2.0.0.0
network 10.0.0.0
import-route ospf 1
[r3]
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.0 0.0.0.255
network 10.1.23.0 0.0.0.255
network 10.1.34.0 0.0.0.255
[r4]
#
ospf 1 router-id 4.4.4.4
import-route rip 1
area 0.0.0.0
network 10.1.34.0 0.0.0.255
#
rip 1
version 2
network 4.0.0.0
network 10.0.0.0
import-route ospf 1
三、重发布后检测路由表
AR1:
AR3:
总结:从图中不难看出,AR1去往OSPF协议中的路由网段均实现负载均衡,AR3同理,若要使AR1进行正确的选路需要使用路由策略规则
四、路由策略:
一、OSPF区域干涉选路(rip同理):
从上图可以得知,AR3去往10.1.12.0网段和2.2.2.0换回的时候是负载均衡,但作为管理员的我们得知AR3去往10.1.12.0 和2.2.2.0网段时经过AR2可以减少带宽。故使用路由策略进行干涉。同理,在AR4上进行选路干涉。
在AR2上进行路由策略:
#
route-policy 11 permit node 10 修改度量,来达到选路效果
if-match ip-prefix 1
apply cost 10
#
route-policy 11 permit node 20
if-match ip-prefix 2
apply cost 10
#
route-policy 11 permit node 60 由于路由策略末尾拒绝所有,所以需要创建一个新的表来允许所有。
#
route-policy aa permit node 10
if-match ip-prefix aa
apply cost 10
apply cost-type type-1 修改类型 由于类型1大于类型2
#
route-policy aa permit node 20
if-match ip-prefix bb
apply cost-type type-1
#
route-policy aa permit node 50
抓流量:
#
ip ip-prefix 1 index 10 permit 4.4.4.0 24
ip ip-prefix 2 index 10 permit 10.1.34.0 24
ip ip-prefix aa index 10 permit 2.2.2.0 24
ip ip-prefix bb index 10 permit 10.1.12.0 24
同理,在AR4上同样进行选路:
#
route-policy 11 permit node 10
if-match ip-prefix 1
apply cost 10
#
route-policy 11 permit node 20
if-match ip-prefix 2
apply cost 10
#
route-policy 11 permit node 60
#
route-policy aa permit node 10
if-match ip-prefix 3
apply cost-type type-1
#
route-policy aa permit node 20
#
ip ip-prefix 1 index 10 permit 3.3.3.0 24
ip ip-prefix 2 index 10 permit 10.1.23.0 24
ip ip-prefix 3 index 10 permit 10.1.14.0 24
ip ip-prefix nn index 10 permit 2.2.2.0 24
二、进行路由策略后,需要重发布技术将策略发布到OSPF中(rip同理)
#
[r4]
import-route rip 1 route-policy aa
#
[r2]
import-route ospf 1 route-policy 11
五、选路进行测试:
AR1:
AR3:
从AR1和AR3的图中我们可以得知,选路已干涉成功。
六、解决由于rip的水平分割而导致的选路不佳问题:
一、特殊情况:
由于不稳定元素而导致路由断开再重连时,由于rip的收敛不及时,rip会因为右侧的ospf重发布进来的路由导致到达2.2.2.0的路由选路不佳,随后在图上会看到下述情况:
二、解决方案:
在AR4上堵塞2.2.2.0的路由以避免AR1选路不佳。
[ar4]
#
interface GigabitEthernet0/0/1
ip address 10.1.14.4 255.255.255.0
rip metricout ip-prefix nn 2
#
ip ip-prefix nn index 10 permit 2.2.2.0 24
七、备份测试:
断开AR3上的S4/0/1接口:
从上图可以看到,即便断开s4/0/1的接口,AR3依然可以有全网的路由。
至此,实验结束,谢谢观看。