实验要求
实验拓扑
配置环回和接口
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 13.1.1.1 24
[r1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 24.1.1.1 24
[r2]int lo0
[r2-LoopBack0]ip add 2.2.2.2 24
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 13.1.1.2 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
[r3]int lo0
[r3-LoopBack0]ip add 3.3.3.3 24
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 24.1.1.2 24
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/1]int g0/0/2
[r4-GigabitEthernet0/0/2]ip add 45.1.1.1 24
[r4]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
[r5]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 56.1.1.1 24
[r5-GigabitEthernet0/0/1]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.1.1.2 24
[r5]int lo0
[r5-LoopBack0]ip add 5.5.5.5 24
[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 56.1.1.2 24
[r6-GigabitEthernet0/0/0]int g0/0/1
[r6-GigabitEthernet0/0/1]ip add 67.1.1.1 24
[r6-GigabitEthernet0/0/1]q
[r6]int lo0
[r6-LoopBack0]ip add 6.6.6.6 24
[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 67.1.1.2 24
[r7-GigabitEthernet0/0/0]int lo0
[r7-LoopBack0]ip add 7.7.7.7 24
启动协议
[r1]rip
[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
[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]net
[r2-ospf-1-area-0.0.0.0]network 24.1.1.1 0.0.0.0
[r3]rip
[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 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.1.1.1 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 4.4.4.4 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 24.1.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 45.1.1.1 0.0.0.0
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]network 5.5.5.5 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 45.1.1.2 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 56.1.1.1 0.0.0.0
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 56.1.1.2 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 67.1.1.1 0.0.0.0
[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.2 0.0.0.0
此时r2
将r7的环回重发布进入ospf
[r7]ospf 1
[r7-ospf-1]import-route direct
多点双向重发布
[r2]rip
[r2-rip-1]import-route ospf 1
[r2-rip-1]q
[r2]ospf
[r2-ospf-1]import-route rip
[r3]rip
[r3-rip-1]import-route ospf 1
[r3-rip-1]q
[r3]ospf 1
[r3-ospf-1]import-route rip
此时会触环,原因是:
R7的环回,发送—R4—R4分别发给R2 R3
R2先进行重发布,将R7环回发布到RIP----R1----R3
R3后进行重发布,R3中有收到R7的环回,同时也收到了R1给R3的R7环回,比较优先级,RIP优先级100,OSPF优先级150.。选左边RIP。
且环回地址的协议变为RIP,且下一跳为13.1.1.1。
若R3再进行重发布,就会把RIP重发布到OSPF中,此时R3为ASBR,虽然优先级相同,度量值明显比从R7到R4使用OSPF的度量值低。
R4选择度量值低的。R4将这条度量值低的发送给R5,R5从R4收到路由,也从R7收到路由,优先级相同且cost值相同,产生负载均衡。
破环
要使R3重发布后,选择右边的OSPF协议。就要修改R3入口处7.7.7.0网段的RIP的优先级,做如下配置。
抓7.7.7.0 24流量,匹配它,修改优先级为151
[r3]ip ip-prefix qq index 10 permit 7.7.7.0 24
[r3]route-policy qq permit node 10
[r3-route-policy]if-match ip-prefix qq
[r3-route-policy]apply preference 151
去RIP调用,只让策略里的优先级改变
[r3-route-policy]q
[r3]rip
[r3-rip-1]preference route-policy qq
可以看到RIP协议中R7的优先级变为151
R3的路由表中显示到R7用的式OSPF协议。不会有环了
r2
[r2]ip ip-prefix qq permit 7.7.7.0 24
[r2]route-policy qq permit node 10
[r2-route-policy]if-match ip-prefix qq
[r2-route-policy]apply preference 151
[r2-route-policy]q
[r2]rip
[r2-rip-1]preference route-policy qq
路径最优
R1到R3环回是一条3.3.3.0 /24(R3发直连路由到RIP)和一条3.3.3.0 /32(OSPF)
[r3-LoopBack0]ip address 3.3.3.3 32
处理负载均衡——使用偏移列表修改度量
用WW抓住两个网段,再进入g0/0/0调用ww使度量加2
就是在R2发给R1时度量加大
[r2]ip ip-prefix ww permit 3.3.3.3 32
[r2]ip ip-prefix ww permit 34.1.1.0 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix ww 2
此时34网段没有负载均衡了
r3
[r3]ip ip-prefix ww permit 23.1.1.0 24
[r3]int g0/0/1
[r3-GigabitEthernet0/0/1]rip metricout ip-prefix ww 2
类型1优于类型2
R2把12网段和自身环回给R4时,变成类型1
R3把13网段和自身环回给R4时,变成类型1
[r2]ip ip-prefix ee permit 12.1.1.0 24
[r2]ip ip-prefix ee permit 2.2.2.0 24
[r2]route-policy ee permit node 10
[r2-route-policy]if-match ip-prefix ee
[r2-route-policy]apply cost-type type-1
[r2-route-policy]q
[r2]route-policy ee permit node 20
[r2-route-policy]q
[r2]ospf 1
[r2-ospf-1]import-route rip route-policy ee
r3
[r3]ip ip-prefix ee permit 13.1.1.0 24
[r3]route-policy ee permit node 10
[r3-route-policy]if-match ip-prefix ee
[r3-route-policy]apply cost-type type-1
[r3-route-policy]q
[r3]route-policy ee permit node 20
[r3-route-policy]q
[r3]ospf 1
[r3-ospf-1]import-route rip route-policy ee