拓扑图
配置接口IP
配置协议
[R1]rip
[R1-rip-1]version 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]rip
[R2-rip-1]ver 2
[R2-rip-1]network 2.0.0.0
[R2-rip-1]network 12.0.0.0
[R2-rip-1]q
[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
[R3]rip
[R3-rip-1]ver 2
[R3-rip-1]network 13.0.0.0
[R3-rip-1]q
[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
查看R4邻居关系
R7重发布
[R7]ospf 1
[R7-ospf-1]import-route direct
查看R4,R6路由表已学到R7环回
R2,R3上做双向重发布
[R2]rip 1
[R2-rip-1]import-route ospf 1
[R2-rip-1]q
[R2]ospf 1
[R2-ospf-1]import-route rip 1
[R3]rip
[R3-rip-1]import-route ospf 1
[R3-rip-1]q
[R3]ospf 1
[R3-ospf-1]import-route rip 1
查看R3,R4路由表,此时R4到7.0.0.0的下一跳是R3,R3到7.0.0.0下一跳是R1,导致环路
因为rip中R7环回的优先级为100,R3丢弃了从ospf学到的R7的环回,R3再将R7的环回传递给R4,R4学到了两条R7的环回,则出现环路
解决环路:修改R1给R3R7环回的路由的优先级,使R3学ospf中的R7环回
[R2]ip ip-prefix b permit 7.7.7.0 24
[R2]route-policy b permit node 10
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix b
[R2-route-policy]apply preference 154
[R2-route-policy]q
[R2]rip 1
[R2-rip-1]preference route-policy b
[R3]ip ip-prefix a permit 7.7.7.0 24
[R3]route-policy aa permit node 10
Info: New Sequence of this List.
[R3-route-policy]if-match ip-prefix a
[R3-route-policy]apply preference 154
[R3-route-policy]q
[R3]rip 1
[R3-rip-1]preference route-policy aa
关闭R3,R4接口查看
[R3-GigabitEthernet0/0/1]shutdown
再次打开接口并查看
[R3-GigabitEthernet0/0/1]undo shutdown
查看R1路由表,R3环回、24网段和34网段为负载均衡,选路不佳
将R3环回工作方式修改为broadcast
[R3]int LoopBack 0
[R3-LoopBack0]ospf network-type broadcast
在R2,R3上使用偏移列表给RIP增加度量
R2:
[R2]ip ip-prefix aa permit 3.3.3.0 24
[R2]ip ip-prefix aa permit 34.1.1.0 24
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]rip metricin ip-prefix aa 2
R3:
[R3]ip ip-prefix aa permit 24.1.1.0 24
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]rip metricin ip-prefix aa 2
将R2环回、12网段和13网段改为类型1
R2:
[R2]ip ip-prefix aa permit 12.1.1.0 24
[R2]ip ip-prefix aa permit 2.2.2.0 24
[R2]route-policy bb permit node 10
Info: New Sequence of this List.
[R2-route-policy]if-match ip-prefix aa
[R2-route-policy]apply cost-type type-1
[R2-route-policy]q
[R2]route-policy bb permit node 20
Info: New Sequence of this List.
[R2-route-policy]q
[R2]ospf 1
[R2-ospf-1]import-route rip 1 route-policy bb
R3:
[R3]ip ip-prefix aa permit 13.1.1.0 24
[R3]route-policy bb permit node 10
Info: New Sequence of this List.
[R3-route-policy]if-match ip-prefix aa
[R3-route-policy]apply cost-type type-1
[R3-route-policy]q
[R3]route-policy bb permit node 20
Info: New Sequence of this List.
[R3-route-policy]q
[R3]ospf 1
[R3-ospf-1]import-route rip 1 route-policy bb
查看路由表
测试