OSPF 多区域配置实验
实验拓扑
实验需求
- 按照图示配置 IP 地址和loopback 接口
- 按照图示分区域配置 OSPF ,实现全网互通
- 为了路由结构稳定,要求路由器使用环回口作为 Router-id
- 在AR3上配置静默接口
- 在OSPF里发布默认路由
- PC1 PING通公网地址
实验步骤
按照图示配置 IP 地址和loopback 接口
AR1
[Huawei-GigabitEthernet0/0/0]ip address 20.20.20.1 24
[Huawei-GigabitEthernet0/0/1]ip address 10.10.10.1 24
AR2
[Huawei-GigabitEthernet0/0/0]ip address 20.20.20.2 24
[Huawei-GigabitEthernet0/0/1]ip address 30.30.30.1 24
[Huawei-LoopBack0]ip address 4.4.4.4 32
AR3
[Huawei-GigabitEthernet0/0/0]ip address 10.10.10.2 24
[Huawei-GigabitEthernet0/0/1]ip address 10.20.1.1 24
[Huawei-LoopBack0]ip address 1.1.1.1 32
AR4
[AR4-GigabitEthernet0/0/0]ip address 30.30.30.2 24
[AR4-GigabitEthernet0/0/1]ip address 23.1.2.1 24
[AR4-LoopBack0]ip address 5.5.5.5 32
AR5
[Huawei-GigabitEthernet0/0/0]ip address 23.1.2.2 24
按照图示分区域配置 OSPF ,实现全网互通
AR1
[Huawei]ospf 1 router-id 2.2.2.2
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]network 10.10.10.0 0.0.0.255
AR2
[Huawei]ospf 1 router-id 2.2.2.2
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]area 2
[Huawei-ospf-1-area-0.0.0.2]network 30.30.30.0 0.0.0.255
AR3
[Huawei]ospf 1 router-id 1.1.1.1
[Huawei-ospf-1]area 1
[Huawei-ospf-1-area-0.0.0.1]network 1.1.1.1 0.0.0.0
[Huawei-ospf-1-area-0.0.0.1]network 10.10.10.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.1]network 10.20.1.0 0.0.0.255
AR4
[AR4]ospf 1 router-id 5.5.5.5
[AR4-ospf-1]area 2
[AR4-ospf-1-area-0.0.0.2]network 5.5.5.5 0.0.0.0
[AR4-ospf-1-area-0.0.0.2]network 30.30.30.0 0.0.0.255
在AR1上查看OSPF 路由表项,发现已经互相学习到了。
[Huawei]dis ip routing-table protocol ospf
OSPF routing table status : <Active>
Destinations : 4 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 OSPF 10 1 D 10.10.10.2 GigabitEthernet0/0/1
4.4.4.4/32 OSPF 10 1 D 20.20.20.2 GigabitEthernet0/0/0
5.5.5.5/32 OSPF 10 2 D 20.20.20.2 GigabitEthernet0/0/0
30.30.30.0/24 OSPF 10 2 D 20.20.20.2 GigabitEthernet0/0/0
在AR1上查看邻居表, Full State状态表示所有交互已经完成
[Huawei]dis ospf peer brief
OSPF Process 1 with Router ID 2.2.2.2
Peer Statistic Information
-------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 4.4.4.4 Full
0.0.0.1 GigabitEthernet0/0/1 1.1.1.1 Full
在AR3设备 上配置静默接口
[Huawei-ospf-1]silent-interface g0/0/1 ////静默接口 只接受 不发送报文
在AR4上配置一条去往公网的默认路由
[AR4-ospf-1]ip route-static 0.0.0.0 0 23.1.2.2
配置ospf 路由协议中发布默认路由
在AR4 OSPF系统视图里配置
[AR4-ospf-1]default-route-advertise
在AR2上查看OSPF路由表可以看到去往公网的默认路由,其他运行ospf的路由器已经都学习到区域内产生的一条OSPF路由
[Huawei]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
--------------------------------------------------------------------
Public routing table : OSPF
Destinations : 6 Routes : 6
OSPF routing table status : <Active>
Destinations : 6 Routes : 6
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 O_ASE 150 1 D 30.30.30.2 GigabitEthernet0/0/1
1.1.1.1/32 OSPF 10 2 D 20.20.20.1 GigabitEthernet0/0/0
2.2.2.2/32 OSPF 10 1 D 20.20.20.1 GigabitEthernet0/0/0
5.5.5.5/32 OSPF 10 1 D 30.30.30.2 GigabitEthernet0/0/1
10.10.10.0/24 OSPF 10 2 D 20.20.20.1 GigabitEthernet0/0/0
10.20.1.0/24 OSPF 10 3 D 20.20.20.1 GigabitEthernet0/0/0
在AR5 上配置一条回程路由
[Huawei]ip route-static 0.0.0.0 0 23.1.2.1
PC1 ping 公网地址
PC>ping 23.1.2.2
Ping 23.1.2.2: 32 data bytes, Press Ctrl_C to break
From 23.1.2.2: bytes=32 seq=1 ttl=251 time=47 ms
From 23.1.2.2: bytes=32 seq=2 ttl=251 time=31 ms
From 23.1.2.2: bytes=32 seq=3 ttl=251 time=47 ms
From 23.1.2.2: bytes=32 seq=4 ttl=251 time=47 ms
From 23.1.2.2: bytes=32 seq=5 ttl=251 time=47 ms
--- 23.1.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/43/47 ms