OSPF实验一
1.实验拓扑图

实验需求
- 按照拓扑图示给设备命名以及配置 IP 地址
- 按照图示分区域配置 OSPF ,实现全网互通
- 为了路由结构稳定,要求路由器使用环回口作为 Router-id,ABR 的环回口宣告进骨干区域
2.配置IP地址和环回口
powershell
[R1]int g0/0
[R1-GigabitEthernet0/0]ip address 10.1.12.1 24
[R1-GigabitEthernet0/0]int g0/1
[R1-GigabitEthernet0/1]ip address 10.1.14.1 24
[R1-GigabitEthernet0/1]int lo0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]quit
powershell
[R2]int g0/0
[R2-GigabitEthernet0/0]ip address 10.1.12.2 24
[R2-GigabitEthernet0/0]int g0/1
[R2-GigabitEthernet0/1]ip address 10.1.23.2 24
[R2-GigabitEthernet0/1]int lo0
[R2-LoopBack0]ip address 2.2.2.2 32
[R2-LoopBack0]quit
powershell
[R3]int g0/0
[R3-GigabitEthernet0/0]ip address 10.1.23.3 24
[R3-GigabitEthernet0/0]int g0/1
[R3-GigabitEthernet0/1]ip address 10.1.35.3 24
[R3-GigabitEthernet0/1]int lo0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]quit
powershell
[R4]int g0/0
[R4-GigabitEthernet0/0]ip address 10.1.14.4 24
[R4-GigabitEthernet0/0]int lo0
[R4-LoopBack0]ip address 4.4.4.4 32
[R4-LoopBack0]quit
powershell
[R5]int g0/0
[R5-GigabitEthernet0/0]ip address 10.1.35.5 24
[R5-GigabitEthernet0/0]int lo0
[R5-LoopBack0]ip address 5.5.5.5 32
[R5-LoopBack0]quit
3.可以查看配置后的结果确保正确





4.按照图示分区域配置 OSPF ,实现全网互通
powershell
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]area 1
[R1-ospf-1-area-0.0.0.1]network 10.1.14.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]quit
[R1-ospf-1]dis th
#
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 10.1.12.0 0.0.0.255
area 0.0.0.1
network 10.1.14.0 0.0.0.255
#
return
powershell
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.1.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.1.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]quit
[R2-ospf-1]dis th
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.1.12.0 0.0.0.255
network 10.1.23.0 0.0.0.255
#
return
powershell
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.1.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[R3-ospf-1]area 2
[R3-ospf-1-area-0.0.0.2]network 10.1.35.0 0.0.0.255
[R3-ospf-1-area-0.0.0.2]quit
[R3-ospf-1]dis th
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 10.1.23.0 0.0.0.255
area 0.0.0.2
network 10.1.35.0 0.0.0.255
#
return
powershell
[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 1
[R4-ospf-1-area-0.0.0.1]network 10.1.14.0 0.0.0.255
[R4-ospf-1-area-0.0.0.1]network 4.4.4.4 0.0.0.0
[R4-ospf-1-area-0.0.0.1]quit
[R4-ospf-1]dis th
#
ospf 1 router-id 4.4.4.4
area 0.0.0.1
network 4.4.4.4 0.0.0.0
network 10.1.14.0 0.0.0.255
#
return
powershell
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]area 2
[R5-ospf-1-area-0.0.0.2]network 10.1.35.0 0.0.0.255
[R5-ospf-1-area-0.0.0.2]network 5.5.5.5 0.0.0.0
[R5-ospf-1-area-0.0.0.2]quit
[R5-ospf-1]dis th
#
ospf 1 router-id 5.5.5.5
area 0.0.0.2
network 5.5.5.5 0.0.0.0
network 10.1.35.0 0.0.0.255
#
return
5.查看是否已经全网互通(查看邻居关系表和路由表)
邻居关系表:
powershell
[R1]display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 10.1.12.2 1 32 Full/BDR GE0/0
Area: 0.0.0.1
Router ID Address Pri Dead-Time State Interface
4.4.4.4 10.1.14.4 1 40 Full/BDR GE0/1
powershell
[R2]display ospf peer
OSPF Process 1 with Router ID 2.2.2.2
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
1.1.1.1 10.1.12.1 1 32 Full/DR GE0/0
3.3.3.3 10.1.23.3 1 31 Full/BDR GE0/1
powershell
[R3]dis ospf peer
OSPF Process 1 with Router ID 3.3.3.3
Neighbor Brief Information
Area: 0.0.0.0
Router ID Address Pri Dead-Time State Interface
2.2.2.2 10.1.23.2 1 31 Full/DR GE0/0
Area: 0.0.0.2
Router ID Address Pri Dead-Time State Interface
5.5.5.5 10.1.35.5 1 36 Full/BDR GE0/1
powershell
[R4]display ospf peer
OSPF Process 1 with Router ID 4.4.4.4
Neighbor Brief Information
Area: 0.0.0.1
Router ID Address Pri Dead-Time State Interface
1.1.1.1 10.1.14.1 1 31 Full/DR GE0/0
powershell
[R5]display ospf peer
OSPF Process 1 with Router ID 5.5.5.5
Neighbor Brief Information
Area: 0.0.0.2
Router ID Address Pri Dead-Time State Interface
3.3.3.3 10.1.35.3 1 38 Full/DR GE0/0
路由表:
powershell
[R1]dis ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0
2.2.2.2/32 O_INTRA 10 1 10.1.12.2 GE0/0
3.3.3.3/32 O_INTRA 10 2 10.1.12.2 GE0/0
4.4.4.4/32 O_INTRA 10 1 10.1.14.4 GE0/1
5.5.5.5/32 O_INTER 10 3 10.1.12.2 GE0/0
10.1.12.0/24 Direct 0 0 10.1.12.1 GE0/0
10.1.12.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.12.255/32 Direct 0 0 10.1.12.1 GE0/0
10.1.14.0/24 Direct 0 0 10.1.14.1 GE0/1
10.1.14.1/32 Direct 0 0 127.0.0.1 InLoop0
10.1.14.255/32 Direct 0 0 10.1.14.1 GE0/1
10.1.23.0/24 O_INTRA 10 2 10.1.12.2 GE0/0
10.1.35.0/24 O_INTER 10 3 10.1.12.2 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
powershell
[R2]display ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTRA 10 1 10.1.12.1 GE0/0
2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0
3.3.3.3/32 O_INTRA 10 1 10.1.23.3 GE0/1
4.4.4.4/32 O_INTER 10 2 10.1.12.1 GE0/0
5.5.5.5/32 O_INTER 10 2 10.1.23.3 GE0/1
10.1.12.0/24 Direct 0 0 10.1.12.2 GE0/0
10.1.12.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.12.255/32 Direct 0 0 10.1.12.2 GE0/0
10.1.14.0/24 O_INTER 10 2 10.1.12.1 GE0/0
10.1.23.0/24 Direct 0 0 10.1.23.2 GE0/1
10.1.23.2/32 Direct 0 0 127.0.0.1 InLoop0
10.1.23.255/32 Direct 0 0 10.1.23.2 GE0/1
10.1.35.0/24 O_INTER 10 2 10.1.23.3 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
powershell
[R3]display ip routing-table
Destinations : 20 Routes : 20
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTRA 10 2 10.1.23.2 GE0/0
2.2.2.2/32 O_INTRA 10 1 10.1.23.2 GE0/0
3.3.3.3/32 Direct 0 0 127.0.0.1 InLoop0
4.4.4.4/32 O_INTER 10 3 10.1.23.2 GE0/0
5.5.5.5/32 O_INTRA 10 1 10.1.35.5 GE0/1
10.1.12.0/24 O_INTRA 10 2 10.1.23.2 GE0/0
10.1.14.0/24 O_INTER 10 3 10.1.23.2 GE0/0
10.1.23.0/24 Direct 0 0 10.1.23.3 GE0/0
10.1.23.3/32 Direct 0 0 127.0.0.1 InLoop0
10.1.23.255/32 Direct 0 0 10.1.23.3 GE0/0
10.1.35.0/24 Direct 0 0 10.1.35.3 GE0/1
10.1.35.3/32 Direct 0 0 127.0.0.1 InLoop0
10.1.35.255/32 Direct 0 0 10.1.35.3 GE0/1
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
powershell
[R4]display ip routing-table
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTER 10 1 10.1.14.1 GE0/0
2.2.2.2/32 O_INTER 10 2 10.1.14.1 GE0/0
3.3.3.3/32 O_INTER 10 3 10.1.14.1 GE0/0
4.4.4.4/32 Direct 0 0 127.0.0.1 InLoop0
5.5.5.5/32 O_INTER 10 4 10.1.14.1 GE0/0
10.1.12.0/24 O_INTER 10 2 10.1.14.1 GE0/0
10.1.14.0/24 Direct 0 0 10.1.14.4 GE0/0
10.1.14.4/32 Direct 0 0 127.0.0.1 InLoop0
10.1.14.255/32 Direct 0 0 10.1.14.4 GE0/0
10.1.23.0/24 O_INTER 10 3 10.1.14.1 GE0/0
10.1.35.0/24 O_INTER 10 4 10.1.14.1 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
powershell
[R5]display ip routing-table
Destinations : 18 Routes : 18
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/32 Direct 0 0 127.0.0.1 InLoop0
1.1.1.1/32 O_INTER 10 3 10.1.35.3 GE0/0
2.2.2.2/32 O_INTER 10 2 10.1.35.3 GE0/0
3.3.3.3/32 O_INTER 10 1 10.1.35.3 GE0/0
4.4.4.4/32 O_INTER 10 4 10.1.35.3 GE0/0
5.5.5.5/32 Direct 0 0 127.0.0.1 InLoop0
10.1.12.0/24 O_INTER 10 3 10.1.35.3 GE0/0
10.1.14.0/24 O_INTER 10 4 10.1.35.3 GE0/0
10.1.23.0/24 O_INTER 10 2 10.1.35.3 GE0/0
10.1.35.0/24 Direct 0 0 10.1.35.5 GE0/0
10.1.35.5/32 Direct 0 0 127.0.0.1 InLoop0
10.1.35.255/32 Direct 0 0 10.1.35.5 GE0/0
127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0
127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
127.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
224.0.0.0/4 Direct 0 0 0.0.0.0 NULL0
224.0.0.0/24 Direct 0 0 0.0.0.0 NULL0
255.255.255.255/32 Direct 0 0 127.0.0.1 InLoop0
可以看到,分别已经学习到了全网所有网段的路由信息
6.测试R4和R5是否能互通
powershell
[R4]ping 10.1.35.5
Ping 10.1.35.5 (10.1.35.5): 56 data bytes, press CTRL+C to break
56 bytes from 10.1.35.5: icmp_seq=0 ttl=252 time=4.299 ms
56 bytes from 10.1.35.5: icmp_seq=1 ttl=252 time=4.779 ms
56 bytes from 10.1.35.5: icmp_seq=2 ttl=252 time=4.987 ms
56 bytes from 10.1.35.5: icmp_seq=3 ttl=252 time=4.054 ms
56 bytes from 10.1.35.5: icmp_seq=4 ttl=252 time=4.801 ms
--- Ping statistics for 10.1.35.5 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 4.054/4.584/4.987/0.349 ms
[R4]%Jul 10 10:32:09:429 2025 R4 PING/6/PING_STATISTICS: Ping statistics for 10.1.35.5: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 4.054/4.584/4.987/0.349 ms.
[R4]
[R4]ping 5.5.5.5
Ping 5.5.5.5 (5.5.5.5): 56 data bytes, press CTRL+C to break
56 bytes from 5.5.5.5: icmp_seq=0 ttl=252 time=4.413 ms
56 bytes from 5.5.5.5: icmp_seq=1 ttl=252 time=3.447 ms
56 bytes from 5.5.5.5: icmp_seq=2 ttl=252 time=2.941 ms
56 bytes from 5.5.5.5: icmp_seq=3 ttl=252 time=5.248 ms
56 bytes from 5.5.5.5: icmp_seq=4 ttl=252 time=5.598 ms
--- Ping statistics for 5.5.5.5 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 2.941/4.329/5.598/1.017 ms
[R4]%Jul 10 10:32:18:707 2025 R4 PING/6/PING_STATISTICS: Ping statistics for 5.5.5.5: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 2.941/4.329/5.598/1.017 ms.
可通,说明已经实现全网互通。