题目:
思路:
为完成实验达成目的,需要明确两个区域内的协议,并且要避免造成环路,故需要改变r3-r1,r3-r4两边的优先级,可以避免造成环路,并且需要达到选路最优,设置匹配规则,并修改路由的类型。此题先配置各路由器的网段和环回地址,再宣告所在路由器的协议,而后再修改优先级避免环路的产生,最后再为达到选路最优,设置匹配规则,并修改路由的类型,达到选路最优。
路由器配置:
r1:
r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 13.1.1.1 24
[r1]rip 1
[r1-rip-1]ver 2
[r1-rip-1]network 1.0.0.0
[r1-rip-1]network 12.0.0.0
[r1-rip-1]network 13.0.0.0
r2:
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]in lo0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2-LoopBack0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 24.1.1.1 24
[r2]rip 1
[r2-rip-1]ver 2
[r2-rip-1]network 2.0.0.0
[r2-rip-1]network 12.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.1 0.0.0.0
[r2-ospf-1]import-route rip
[r2-rip-1]import-route os 1
[r2]ip ip-prefix er permit 3.3.3.3 32
[r2]ip ip-prefix er permit 34.1.1.0 24
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix er 2
[r2]ip ip-prefix rr permit 12.1.1.0 24
[r2]ip ip-prefix rr permit 2.2.2.0 24
[r2]route-policy rr permit node 10
[r2-route-policy]if-match ip-prefix rr
[r2-route-policy]apply cost-type type-1
[r2]route-policy rr permit node 20
[r2-ospf-1]import-route rip route-policy rr
r3:
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 34.1.1.1 24
[r3-GigabitEthernet0/0/0]int lo0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 13.1.1.2 24
[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.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1]rip 1
[r3-rip-1]ver 2
[r3-rip-1]network 13.0.0.0
[r3-ospf-1]import-route rip
[r3-rip-1]import-route os 1
[r3]ip ip-prefix a permit 7.7.7.0 24
[r3]route-policy qq permit node 10
[r3-route-policy]if-match ip-prefix a
[r3-rip-1]preference 151 route-policy qq
[r3]route-policy qq permit node 10
[r3-route-policy]apply preference 151
[r3-rip-1]preference route-policy qq
[r3]int lo0
[r3-LoopBack0]ip add 3.3.3.3 32
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]rip metricout ip-prefix we 2
[r3]route-policy rr permit node 10
[r3-route-policy]if-match ip-prefix rr
[r3-route-policy]apply cost-type type-1
[r3]route-policy rr permit node 20
[r3-ospf-1]import-route rip route-policy rr
[r3]ip ip-prefix we permit 2.2.2.0 24
r4:
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 24.1.1.2 24
[r4-GigabitEthernet0/0/0]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]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]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:
[r5-GigabitEthernet0/0/1]int g0/0/0
[r5-GigabitEthernet0/0/2]ip add 45.1.1.2 24
[r5]int lo0
[r5-LoopBack0]ip add 5.5.5.5 24
[r5-LoopBack0]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 56.1.1.1 24
[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:
[r6]int lo0
[r6-LoopBack0]ip add 6.6.6.6 24
[r6-LoopBack0]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]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:
[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
[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
[r7-ospf-1]import-route direct
验证命令: