- OSPF架构:所有非骨干区域必须骨干区域相邻,如果不相邻必须有虚链路技术
- 配置的位置:区域边界路由器
- 注意:每个OSPF路由器都有一个router-id(标识符)
- 相当于人的身份证
- 默认路由器会自动选择本路由器接口的一个IP地址作为router-id.并且每台路由器的router-id必须是唯一
- 拓扑图:
-
- 思科配置:
- 1、规划网断
- 2、配置每个节点IP地址
- R0:
- enable
- conf t
- interface f0/0
- no shutdown
- ip address 192.168.10.1 255.255.255.0
- exit
- R1:
- enable
- conf t
- interface f0/0
- no shutdown
- ip address 192.168.10.2 255.255.255.0
- exit
- interface f0/1
- no shutdown
- ip address 192.168.20.1 255.255.255.0
- exit
- R2:
- enable
- conf t
- interface f0/0
- no shutdown
- ip address 192.168.20.2 255.255.255.0
- exit
- interface f0/1
- no shutdown
- ip address 192.168.30.1 255.255.255.0
- exit
- R3:
- enable
- conf t
- interface f0/0
- no shutdown
- ip address 192.168.30.2 255.255.255.0
- exit
- interface f0/1
- no shutdown
- ip address 192.168.40.1 255.255.255.0
- exit
- R4:
- enable
- conf t
- interface f0/0
- no shutdown
- ip address 192.168.40.2 255.255.255.0
- exit
- interface f0/1
- no shutdown
- ip address 192.168.50.1 255.255.255.0
- exit
- R0:
- 3、配置OSPF多区域
- R0:
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.10.0 0.0.0.255 area 0
- R1:
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.10.0 0.0.0.255 area 0
- Router(config-router)#network 192.168.20.0 0.0.0.255 area 1
- R2:
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.20.0 0.0.0.255 area 1
- Router(config-router)#network 192.168.30.0 0.0.0.255 area 1
- R3:
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.30.0 0.0.0.255 area 1
- Router(config-router)#network 192.168.40.0 0.0.0.255 area 2
- R4:
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.40.0 0.0.0.255 area 2
- Router(config-router)#network 192.168.50.0 0.0.0.255 area 2
- R0:
- 4、配置虚链路
- 方法①
- 修改生份证router-id(标识符)
- Router(config)#router ospf 1
- Router(config-router)#router-id 1.1.1.1(这个地址可以不存在,但是必须唯一)
- Router#clear ip ospf process #重启ospf进程让身份证生效。
- Reset ALL OSPF processes? [no]: yes
- R1:
- 注意:查看身份证一定保证身份证的router-id(ip),这个Ip一定要是两个区域之间的区域的接口IP地址
- Router ospf 1
- Router-id 192.168.20.1
- End
- Clear ip ospf processs
- yes
- Router(config)#router ospf 1
- Router(config-router)#area 1 virtual-link 192.168.30.2
- 注意:area 区域号(两个区域之间的区域号)virtual-link 身份证(对方的router-id)
- R3:
- Router ospf 1
- Router-id 192.168.30.2
- End
- Clear ip ospf processs
- yes
- Router(config)#router ospf 1
- Router(config-router)#area 1 virtual-link 192.168.20.1
- 注意:area 区域号(两个区域之间的区域号)virtual-link 身份证(对方的router-id)
- 修改生份证router-id(标识符)
- 方法②
- 在两台区域边界路由器上进行做虚链路技术。
- R4---------R6
- 1:创建一个回环口
- Router(config)#interfaceloopback 1
- Router(config-if)#IP address 4.4.4.4 255.255.255.0
- 2:将回环口NETWORK在两台边界路由器之间的区域
- Router(config)#routerospf 1
- Router(config-router)#network 4.4.4.0 0.0.0.255 area 1
- 3:将回环口配置成ROUTER-ID
- Router(config)#routerospf 1
- Router(config-router)#router-id4.4.4.4
- Router(config-router)#end
- Router#clearip ospf process
- Reset ALL OSPF processes? [no]: yes
- 4:创建虚链路
- Router(config)#routerospf 1
- Router(config-router)#area 1(两个边界路由器之间的区域)virtual-link 6.6.6.6(对方的ID)
- 1:创建一个回环口
- R6:
- 1:创建一个回环口
- Router(config)#interface loopback 1
- Router(config-if)#ip address 6.6.6.6255.255.255.0
- Router(config-if)#exit
- 2:将回环口NETWORK在两台边界路由器之间的区域
- Router(config)#router ospf 1
- Router(config-router)#network 6.6.6.00.0.0.255 area 1
- Router(config-router)#exit
- 3:将回环口配置成ROUTER-ID
- Router(config)#router ospf 1
- Router(config-router)#router-id 6.6.6.6
- Router(config-router)#end
- Router#clear ip ospf process
- Reset ALL OSPF processes? [no]: yes
- 4:创建虚链路
- Router(config)#ROUTEROSPF 1
- Router(config-router)#AREA 1 virtual-link 4.4.4.4
- 1:创建一个回环口
- 方法①
- 华为配置:ensp
- 拓扑图:
-
- 1、规划网断
- 2、配置节点IP地址
- R1:
- <Huawei>system-view
- [Huawei]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]ip add 10.1.12.1 24
- [Huawei-GigabitEthernet0/0/1]q
- [Huawei]int LoopBack 0
- [Huawei-LoopBack0]ip add 1.1.1.1 32
- [Huawei-LoopBack0]q
- R2:
- <Huawei>system-view
- [Huawei]int g0/0/0
- [Huawei-GigabitEthernet0/0/0]ip add 10.1.12.2 24
- [Huawei-GigabitEthernet0/0/0]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]ip add 10.1.23.1 24
- [Huawei-GigabitEthernet0/0/1]q
- [Huawei]int LoopBack 0
- [Huawei-LoopBack0]ip add 2.2.2.2 32
- [Huawei-LoopBack0]q
- R3:
- <Huawei>system-view
- [Huawei]int g0/0/0
- [Huawei-GigabitEthernet0/0/0]ip add 10.1.23.2 24
- [Huawei-GigabitEthernet0/0/0]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]ip add 10.1.34.1 24
- [Huawei-GigabitEthernet0/0/1]q
- [Huawei]int LoopBack 0
- [Huawei-LoopBack0]ip add 3.3.3.3 32
- R4:
- <Huawei>system-view
- [Huawei]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]ip add 10.1.34.2 24
- [Huawei-GigabitEthernet0/0/1]q
- [Huawei]int LoopBack 0
- [Huawei-LoopBack0]ip add 4.4.4.4 32
- R1:
- 3、配置OSPF多区域
- R1:
- [Huawei]ospf 1 router-id 1.1.1.1
- [Huawei-ospf-1]area 0
- [Huawei-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.0
- R2:
- [Huawei]ospf 1 router-id 2.2.2.2
- [Huawei-ospf-1]area 0
- [Huawei-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.0]q
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]network 10.1.23.0 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.1]network 2.2.2.0 0.0.0.0
- R3:
- [Huawei]ospf 1 router-id 3.3.3.3
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]network 10.1.23.0 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.1]network 3.3.3.0 0.0.0.0
- [Huawei-ospf-1-area-0.0.0.1]q
- [Huawei-ospf-1]area 2
- [Huawei-ospf-1-area-0.0.0.2]network 10.1.34.0 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.2]q
- R4:
- [Huawei]ospf 1 router-id 4.4.4.4
- [Huawei-ospf-1]area 2
- [Huawei-ospf-1-area-0.0.0.2]network 10.1.34.2 0.0.0.255
- [Huawei-ospf-1-area-0.0.0.2]network 4.4.4.0 0.0.0.0
- R1:
- 4、配置虚链路
- R2:
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]vlink-peer3.3.3.3
- R3:
- [Huawei-ospf-1]area 1
- [Huawei-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2
- 如需引入外部路由在边缘路由执行:
- [Huawei-ospf-1]default-route-advertisealways (路由的注入)
- R2:
- 拓扑图: