实验拓扑图
一、为所有路由器配置ip
R1:
interface GigabitEthernet0/0/0
ip address 14.1.12.1 255.255.255.0
interface GigabitEthernet0/0/1
ip address 14.1.13.1 255.255.255.0
interface LoopBack1
ip address 10.1.1.1 255.255.255.0
interface LoopBack2
ip address 10.2.1.1 255.255.255.0
R2:
interface GigabitEthernet0/0/0
ip address 14.1.12.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 14.1.24.2 255.255.255.0
interface LoopBack1
ip address 10.1.2.1 255.255.255.0
interface LoopBack2
ip address 10.2.2.1 255.255.255.0
R3:
interface GigabitEthernet0/0/0
ip address 14.1.34.3 255.255.255.0
interface GigabitEthernet0/0/1
ip address 14.1.13.3 255.255.255.0
interface GigabitEthernet0/0/2
ip address 14.0.35.3 255.255.255.0
interface GigabitEthernet3/0/0
ip address 14.0.36.3 255.255.255.0
R4:
interface GigabitEthernet0/0/0
ip address 14.1.34.4 255.255.255.0
interface GigabitEthernet0/0/1
ip address 14.1.24.4 255.255.255.0
interface GigabitEthernet0/0/2
ip address 14.0.46.4 255.255.255.0
interface GigabitEthernet3/0/0
ip address 14.0.45.4 255.255.255.0
R5:
interface GigabitEthernet0/0/0
ip address 14.0.45.5 255.255.255.0
interface GigabitEthernet0/0/2
ip address 14.0.35.5 255.255.255.0
interface LoopBack1
ip address 10.1.5.1 255.255.255.0
interface LoopBack2
ip address 10.2.5.1 255.255.255.0
R6:
interface GigabitEthernet0/0/0
ip address 14.0.36.6 255.255.255.0
interface GigabitEthernet0/0/0
ip address 14.0.36.6 255.255.255.0
interface LoopBack1
ip address 10.1.6.1 255.255.255.0
interface LoopBack2
ip address 10.2.6.6 255.255.255.0
配置ospf
R1:
ospf 1 router-id 1.1.1.1
area 0.0.0.1
network 10.1.1.0 0.0.0.255
network 10.2.1.0 0.0.0.255
network 14.1.0.0 0.0.255.255
R2:
ospf 1 router-id 2.2.2.2
area 0.0.0.1
network 10.1.2.0 0.0.0.255
network 10.2.2.0 0.0.0.255
network 14.1.0.0 0.0.255.255
R3:
ospf 1 router-id 3.3.3.3
area 0.0.0.1
network 14.1.0.0 0.0.255.255
ospf 2 router-id 3.3.3.3
area 0.0.0.0
network 14.0.0.0 0.0.255.255
R4:
ospf 1 router-id 4.4.4.4
area 0.0.0.1
network 14.1.0.0 0.0.255.255
ospf 2 router-id 4.4.4.4
area 0.0.0.0
network 14.0.0.0 0.0.255.255
R5:
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 10.1.5.0 0.0.0.255
network 10.2.5.0 0.0.0.255
network 14.0.0.0 0.0.255.255
R6:
ospf 1 router-id 6.6.6.6
area 0.0.0.0
network 10.1.6.0 0.0.0.255
network 10.2.6.0 0.0.0.255
network 14.0.0.0 0.0.255.255
抓取路由r3抓的路由应为10.2网段的路由
[r3]ip ip-prefix a1 permit 10.2.1.0 24
[r3]ip ip-prefix a2 permit 10.2.2.0 24
[r3]ip ip-prefix a3 permit 10.2.5.0 24
[r3]ip ip-prefix a4 permit 10.2.6.0 24
r4配置相同
对需要备份的路由将cost值增大,即进行备份
[r3]route-policy 1 permit node 10
[r3-route-policy]if-match ip-prefix a1
[r3-route-policy]apply cost 10
[r3-route-policy]q
在进行重发布
r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]import-route ospf 2 route-policy 3
[r3-ospf-1]import-route ospf 2 route-policy 4
[r3]ospf 2 router-id 3.3.3.3
[r3-ospf-1]import-route ospf 1 route-policy 1
[r3-ospf-1]import-route ospf 1 route-policy 2