ospf单区域和多区域
1.ospf 单区域
-
- 思科单区域配置:
- R1(config)#routerospf 1
- R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
- R1(config-router)#network 1.1.1.0 0.0.0.255 area 0
- R2(config)#router ospf 1
- R2(config-router)#network 0.0.0.0 0.0.0.0 area 0
- 思科单区域配置:
- 2.ospf 多区域
-
- 1. :区域与区域的间隔是路由器。
- 2:区域划分。
- A:骨干区域(area 0)
- B:非骨干区域(非area 0)
- 架构:所有非骨干区域必须与骨干区域相邻。如果不相邻必须采用虚链路技术实现通信。
- 3 .
- 4.启用ospf路由协议:
- 思科配置
- Router0
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.10.00.0.0.255 area 0
- Router1
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.10.0 0.0.0.255area 0
- Router(config-router)#network 192.168.20.00.0.0.255 area 1
- Router2
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.20.00.0.0.255 area 1
- Router(config-router)#network 192.168.30.00.0.0.255 area 1
- Router3
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.30.00.0.0.255 area 1
- Router(config-router)#network 192.168.40.00.0.0.255 area 2
- Router4
- Router(config)#router ospf 1
- Router(config-router)#network 192.168.40.00.0.0.255 area 2
- Router(config-router)#network 192.168.50.00.0.0.255 area 2
- Router0
- 华为配置
-
- 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-ospf-1]area 0
- [Huawei-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255
- 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
- OSPF router-id,每个路由器都有一个router-id,router-id其实就是一个IP地址,并且所有router-id不能重复。其实就是一个身份证。
- [Huawei]int LoopBack 0 创建虚拟地址配置为ospf的router-id
- [Huawei-LoopBack0]ip add 2.2.2.2 32
- [Huawei-LoopBack0]q
- [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.2 0.0.0.0 把[Huawei-LoopBack0] 的 地址加入area 1 共有的区域
- 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
- [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.3 0.0.0.0 把[Huawei-LoopBack0] 的 地址加入area 1 共有的区域
- [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>system-view
- [Huawei]int g0/0/1
- [Huawei-GigabitEthernet0/0/1]q
- [Huawei-ospf-1]area 2
- [Huawei-ospf-1-area-0.0.0.2]network 10.1.34.2 0.0.0.255
- [Huawei-GigabitEthernet0/0/1]ip add 10.1.34.2 24
- 现在我们在R2和R3做虚链路:
- 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
- R2:
-
- 思科配置
-