题目:
内容:
地址划分:
配置R1,R2,R3,R4的接口地址与环回地址
R1配置
环回地址配置:
[r1]interface LoopBack 0
[r1-LoopBack0]ip address 1.1.1.1 2接口地址配置:
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.0.0.1 24
[r1]interface GigabitEthernet 0/0/1
[r1-GigabitEthernet0/0/1]ip address 13.0.0.1 24
R2配置
环回地址配置:
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 2.2.2.2 24
接口地址配置:
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip address 12.0.0.2 24
[r2]interface GigabitEthernet 0/0/1[r2-GigabitEthernet0/0/1]ip address 23.0.0.1 24
R3配置
环回地址配置:
[r3]interface LoopBack 0
[r3-LoopBack0]ip address 3.3.3.3 24
接口地址配置:
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ip address 13.0.0.2 24
[r3]interface GigabitEthernet 0/0/1[r3-GigabitEthernet0/0/1]ip address 24.0.0.1 24
R4配置
环回地址配置:
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 4.4.4.4 24
接口地址配置:
[r4]interface GigabitEthernet 0/0/0[r4-GigabitEthernet0/0/0]ip address 24.0.0.2 24
[r4]interface GigabitEthernet 0/0/1[r4-GigabitEthernet0/0/1]ip address 23.0.0.2 24
进行RIP和OSPF配置
R1配置
[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配置
R2的rip宣告
[r2]rip
[r2-rip-1]version 2
[r2-rip-1]network 2.0.0.0
[r2-rip-1]network 12.0.0.0R2的ospf宣告
[r2]ospf
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
R3配置
R3的rip宣告
[r3]rip
[r3-rip-1]version 2
[r3-rip-1]network 13.0.0.0R2的ospf宣告
[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 24.0.0.1 0.0.0.0
R4配置
[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 23.0.0.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 24.0.0.2 0.0.0.0
查看R4的邻居表:
在R3,R2中进行双向重发布
R2操作:
[r2]ospf 1
[r2-ospf-1]import-route rip
[r2]rip
[r2-rip-1]import-route ospf
R3操作:
[r3]rip
[r3-rip-1]import-route ospf
[r3]ospf
[r3-ospf-1]import-route rip
在R1中查看路由表
因为在R2的路由表中通过OSPF学到的是3.3.3.3/32这条拓扑,但是R3的直连拓扑是3.3.3.0/24,
R1学到了这两条路径,但是这是一种特殊情况,只需要更改R3环回接口类型为broadcast 就可以解决。
命令:
[r3]interface LoopBack 0
[r3-LoopBack0]ospf network-type broadcast
再次查看R1的路由表:
优化R1路由表:
优化前的R1路由表
优化23.0.0.0 24拓扑
[r3]ip ip-prefix aa permit 23.0.0.0 24
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]rip metricout ip-prefix aa 10
优化3.3.3.0 24拓扑
[r2]ip ip-prefix aa permit 3.3.3.0 24
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix aa 10
优化24.0.0.0 24 拓扑
[r2]ip ip-prefix aa permit 24.0.0.0 24
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]rip metricout ip-prefix aa 10
优化后R1路由表:
优化R4路由表:
优化前R4路由表
优化2.2.2.0 24 拓扑:
[r3]ip ip-prefix cc permit 2.2.2.0 24
[r3]route-policy aa permit node 10
[r3-route-policy]if-match ip-prefix cc
[r3-route-policy]apply cost 10
优化12.0.0.0 24拓扑:
[r3]ip ip-prefix cc permit 12.0.0.0 24
[r3]route-policy aa permit node 20
[r3-route-policy]if-match ip-prefix cc
[r3-route-policy]apply cost 10
在OSPF中调用路由策略:
[r3]ospf
[r3-ospf-1]import-route rip route-policy aa
在R3中执行[r3]route-policy aa permit node 1000创建一张空表放通所有剩下的路由信息
优化13.0.0.0 24拓扑:
[r2]ip ip-prefix bb permit 13.0.0.0 24
[r2]route-policy aa permit node 10
[r2-route-policy]if-match ip-prefix bb
[r2-route-policy]apply cost 10
在OSPF中调用路由策略:
[r2]ospf
[r2-ospf-1]import-route rip route-policy aa
在R2中执行[r2]route-policy aa permit node 1000创建一张空表放通所有剩下的路由信息
查看优化后的R4路由表: