实验要求
1.首先做基本配置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[R1]int l0
[R1-LoopBack0]ip address 1.1.1.1 24[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 23.1.1.1 24
[R2]int l0
[R2-LoopBack0]ip address 2.2.2.2 24[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 23.1.1.2 24
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 34.1.1.1 24
[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip address 36.1.1.1 24
[R3]int l0
[R3-LoopBack0]ip address 3.3.3.3 24[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 34.1.1.2 24
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]ip address 45.1.1.1 24
[R4]inter l0
[R4-LoopBack0]ip address 4.4.4.4 24[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip address 45.1.1.2 24
[R5-GigabitEthernet0/0/0]int g0/0/01
[R5-GigabitEthernet0/0/1]ip address 56.1.1.2 24
[R5]int l0
[R5-LoopBack0]ip address 5.5.5.5 24[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip address 36.1.1.2 24
[R6-GigabitEthernet0/0/0]int g0/0/1
[R6-GigabitEthernet0/0/1]ip address 56.1.1.1 24
[R6]int l0
[R6-LoopBack0]ip address 6.6.6.6 24
2、在设备R1-R2-R3-R4-R6上启动OSPF协议,并宣告网段
[R1]ospf 1 router-id 11.11.11.11
[R1-ospf-1]a 0
[R1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255[R2]ospf 1 router-id 92.2.2.2
[R2-ospf-1]a 0
[R2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0[R3]ospf 1 router-id 93.3.3.3
[R3-ospf-1]a 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 36.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 94.4.4.4
[R4-ospf-1]a 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 4.4.4.4 0.0.0.0
[R6]ospf 1 router-id 96.6.6.6
[R6-ospf-1]a 0
[R6-ospf-1-area-0.0.0.0]network 36.1.1.0 0.0.0.255
[R6-ospf-1-area-0.0.0.0]network 6.6.6.6 0.0.0.0
3、在设备R4-R5-R6上启动RIP协议、并宣告网段
[R4]rip
[R4-rip-1]version 2
[R4-rip-1]network 45.0.0.0[R5]rip
[R5-rip-1]version 2
[R5-rip-1]network 45.0.0.0
[R5-rip-1]network 56.0.0.0
[R5-rip-1]network 5.0.0.0[R6]rip
[R6-rip-1]version 2
[R6-rip-1]network 56.0.0.0
4、将R1环回以重发布方式引入OSPF网络
[r1]ospf 100
[r1-ospf-100]import-route direct
5、在R4/R6上进行双点双向重发布
[R4]ospf
[R4-ospf-1]import-route rip 1
[R4]rip
[R4-rip-1]import-route ospf 1[R6]ospf
[R6-ospf-1]import-route rip 1
[R6]rip
[R6-rip-1]import-route ospf 1
6.将ospf中的环回接口改成broadcast
[r1]interface LoopBack 0
[r1-LoopBack0]ospf network-type broadcast[r2]interface LoopBack 0
[r2-LoopBack0]ospf network-type broadcast[r3]interface LoopBack 0
[r3-LoopBack0]ospf network-type broadcast
[r4]interface LoopBack 0
[r4-LoopBack0]ospf network-type broadcast修改原因:
华为默认环回接口在OSPF协议下网络类型为P2P,32位主机路由学习,R1先从R3处学习了一条掩码为24的路由;R2又将自己从R3处学到的掩码为32的路由发给R1,因此表中会出现24和32位的路由信息
7.查看路由表
发现R1的环回在R3R4R5R6之间形成了路由环路
8.产生原因
在路由器R1上进行重发布,将R1的环回接口重发布到OSPF网络中,此时1.1.1.0/24的优先级为150,之后在R4、R6上配置双向双点重发布,路由器R4、R6分别将1.1.1.0/24的路由信息发送到RIP网络中,此时在RIP网络中1.1.1.0/24的优先级为100,当R5将1.1.1.0/24的路由信息发送到R6时,由于R5发送的路由信息优先级较小,路由器优先选择优先级较小的加入路由表,会将路由器R6的路由表刷新,导致路由环路的产生
9. 解决环路
在R6上修改1.1.1.0路由信息的优先级
[r6]ip ip-prefix a permit 1.1.1.0 24
[r6]route-policy a permit node 10
[r6-route-policy]if-match interface
[r6-route-policy]if-match ip-prefix a
[r6-route-policy]apply preference 151
[r6]rip 100
[r6-rip-100]preference route-policy a
环路消失
10. 解决负载均衡的问题
[r5]ip ip-prefix c2 permit 4.4.4.0 24
[r5]route-policy c2 permit node 20
[r5-route-policy]if-match ip-prefix c1
[r5-route-policy]apply cost-type type-1
[r5-GigabitEthernet0/0/1]rip metricin ip-prefix c2 2[r6]ip ip-prefix b permit 4.4.4.0 24
[r6]ip ip-prefix b permit 34.1.1.0 24
[r6]int g0/0/1
[r6-GigabitEthernet0/0/1]rip metricout ip-prefix b2[r4]ip ip-prefix b permit 36.1.1.0 24
[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]rip metricout ip-prefix b 2[r4]ip ip-prefix w permit 56.1.1.0 24
[r4]ip ip-prefix w permit 6.6.6.0 24
[r4]route-policy e permit node 10
[r4-route-policy]if-match ip-prefix w
[r4-route-policy]apply cost-type type-1
[r4]route-policy e permit node 20
[r4]ospf
[r4-ospf-1]import-route rip route-policy e[r6]ip ip-prefix w permit 45.1.1.0 24
[r6]route-policy w permit node 10
[r6-route-policy]if-match ip-prefix w
[r6-route-policy]apply cost-type type-1
[r6]route-policy w permit node 2
[r6]ospf
[r6-ospf-1]import-route rip 1 route-policy w