目标:
1、首先对每个路由器进行接口ip的配置
r1:
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0]int gi 0/0/1
[r1-GigabitEthernet0/0/1]ip add 13.1.1.1 24
[r1-GigabitEthernet0/0/1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
r2:
[r2]int lo0
[r2-LoopBack0]ip ad 2.2.2.2 24
[r2-LoopBack0]int gi 0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int gi 0/0/1
[r2-GigabitEthernet0/0/1]ip add 24.1.1.1 24
r3:
[r3]in lo0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int gi 0/0/0
[r3-GigabitEthernet0/0/0]ip add 34.1.1.1 24
[r3-GigabitEthernet0/0/0]int gi 0/0/1
[r3-GigabitEthernet0/0/1]ip add 13.1.1.2 24
r4:
[r4]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]int gi 0/0/0
[r4-GigabitEthernet0/0/0]ip add 24.1.1.2 24
[r4-GigabitEthernet0/0/0]int gi 0/0/1
[r4-GigabitEthernet0/0/1]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/1]int gi 0/0/2
[r4-GigabitEthernet0/0/2]ip add 45.1.1.1 24
r5:
[r5]int lo0
[r5-LoopBack0]ip add 5.5.5.5 24
[r5-LoopBack0]int gi 0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.1.1.2 24
[r5-GigabitEthernet0/0/0]int gi 0/0/1
[r5-GigabitEthernet0/0/1]ip add 56.1.1.1 24
r6:
[r6]int lo0
[r6-LoopBack0]ip add 6.6.6.6 24
[r6-LoopBack0]int gi 0/0/0
[r6-GigabitEthernet0/0/0]ip add 56.1.1.2 24
[r6-GigabitEthernet0/0/0]int gi 0/0/1
[r6-GigabitEthernet0/0/1]ip add 67.1.1.1 24
r7:
[r7]int lo0
[r7-LoopBack0]ip add 7.7.7.7 24
[r7-LoopBack0]int gi 0/0/0
[r7-GigabitEthernet0/0/0]ip add 67.1.1.2 24
2、下来在在应该启动RIP/OSPF的路由器上启动动态路由协议进行路由的学习
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]network 12.0.0.0
[r1-rip-1]network 13.0.0.0
[r1-rip-1]network 1.0.0.0
[r2]rip 1
[r2-rip-1]version 2
[r2-rip-1]network 12.0.0.0
[r2-rip-1]network 2.0.0.0
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 24.1.1.0 0.0.0.255
[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 34.1.1.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]network 67.1.1.0 0.0.0.255
到现在为止-宣告了rip的路由器仅仅只知道rip学到的路由和直连,宣告了OSPF的路由器仅仅知道OSPF学到的路由,并且他们都不知道r7的7.7.7.7的存在
3、先在r7上进行单向重发布,再到r2,r4上进行双向重发布
[r7]ospf 1
[r7-ospf-1]import-route direct
现在除了r1其他路由器的路由表上都有了去r7环回7.7.7.7的信息
下来在r2,r4上进行双向重发布让r1可以学习到OSPF,让右边的可以学习到RIP
[r2]rip 1
[r2-rip-1]import-route ospf 1
[r2]ospf 1
[r2-ospf-1]import-route rip 1
[r3]rip 1
[r3-rip-1]import-route ospf 1
[r3]ospf 1
[r3-ospf-1]import-route rip 1
这时去观察r1的路由表会发现在7.7.7.7传入r1时出现了回路
这时因为在7.7.7.7刚传入r2时r2有双向重发布r3没有双向重发布所以只有选择走r2到r1再到r3在r1到r3时度量为100,当在r3上做了双向重发布后7.7.7.7会尝试从r4传到r3但是由于在OSPF中5类优先级为150比100大所以不会选择该路径这样就出现了环路
解决方案:修改r1->r4时7.7.7.7的度量为151让他正常的走r4->r3这条路
[r3]ip ip-prefix oo permit 7.7.7.0 24
[r3]route-policy oo permit node 10
Info: New Sequence of this List.
[r3-route-policy]apply preference 151
[r3-route-policy]q
[r3]rip 1
[r3-rip-1]preference route-policy oo
这时就没有了环路
但是这里注意:r2上也有可能会遇到出现环路的可能,为了避免这种情况出现在r2上也修改优先级
4、现在就去进行策略路由让所有选路都为最佳选路
这时去观察r1的路由表会发现
这时修改3.3.3.3的掩码为32位
[r3-LoopBack0]undo ip add
[r3-LoopBack0]ip add 3.3.3.3 32
这时观察会发现恢复为一条:
现在r1到OSPF区域需要修改的选路有:
解决方案:增加不佳选路的度量
[r3]ip ip-prefix a permit 24.1.1.0 24
[r3]int gi 0/0/1
[r3-GigabitEthernet0/0/1]rip metricout ip-prefix a 2
[r2]ip ip-prefix b permit 3.3.3.0 32
[r2]ip ip-prefix b permit 34.1.1.0 24
[r2]int GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix b 2
这时r1的所有选路都为最佳了
下来修改r4的选路:
r4需要优化的选路:
解决方案:增加好的选路的优先级
[r2]ip ip-prefix c permit 12.1.1.0 24
[r2]ip ip-prefix c permit 2.2.2.2 24
[r2]route-policy c permit node 10
Info: New Sequence of this List.
[r2-route-policy]apply cost-type type-1
[r2-route-policy]q
[r2]route-policy c permit node 20
Info: New Sequence of this List.
[r2-route-policy]q
[r2]ospf 1
[r2-ospf-1]import-route rip route-policy c
[r3]ip ip-prefix c permit 13.1.1.0 24
[r3]route-policy c permit node 10
Info: New Sequence of this List.
[r3-route-policy]apply cost-type type-1
[r3-route-policy]q
[r3]route-policy c permit node 20
Info: New Sequence of this List.
[r3-route-policy]q
[r3-ospf-1]q
[r3]ospf 1
[r3-ospf-1]import-route rip route-policy c
现在r4的路由表所有选路都为最佳选路了
检测: