OSPF实验一

OSPF实验一

1.实验拓扑图
实验需求
  1. 按照拓扑图示给设备命名以及配置 IP 地址
  2. 按照图示分区域配置 OSPF ,实现全网互通
  3. 为了路由结构稳定,要求路由器使用环回口作为 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.

可通,说明已经实现全网互通。

相关推荐
阿沁QWQ20 分钟前
应用层协议和JSON的使用
运维·服务器·网络
她说人狗殊途22 分钟前
通信子网 V
网络·智能路由器
运维开发王义杰26 分钟前
不止于监控:深入剖析OpenTelemetry的可观察性生态体系
运维
LCG元30 分钟前
基于MCP的CI/CD流水线:自动化部署到云平台的实践
运维·ci/cd·自动化
Do vis82434 分钟前
STM32第二十天 ESP8266-01S和电脑实现串口通信(3)
网络
I'mSQL1 小时前
C#与FX5U进行Socket通信
运维·服务器·自动化·wpf
Fanmeang1 小时前
OSPF与BGP的联动特性实验案例
运维·网络·华为·ospf·bgp·路由黑洞·ospf联动bgp
DoraBigHead2 小时前
第三章 · 数据链路层:打包大师,局域江湖
网络协议
捉鸭子2 小时前
转转APP逆向
爬虫·python·网络安全·网络爬虫
哈哈浩丶2 小时前
Linux驱动开发2:字符设备驱动
linux·运维·驱动开发