OSPF单区域配置

OSPF单区域配置

实验环境:华为模拟器eNSP
现在有这样一个拓扑图:

我想要让R1可以pingR3,显然目前是不行的:

<R1>ping 192.168.2.2
PING 192.168.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 192.168.2.2 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss

查看一下路由器R1的路由表:

<R1>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 4 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0

发现只有自己的IP地址,说明ping不通是正常的,现在我们来配置OSPF来让R1可以pingR3

<R1>sy
[R1]ospf //启用ospf进程
[R1-ospf-1]area 0 //区域号
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 //宣告路由

<R2>sy
[R2]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255

<R3>sy
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255

这样就配好了,去R1上查看一下路由表:

<R1>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.1 Ethernet0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
192.168.2.0/24 OSPF 10 2 D 192.168.1.2 Ethernet0/0/0

可以看到已经通过OSPF学到了路由器R3的路由,再来ping一下R3试试:

<R1>ping 192.168.2.2
PING 192.168.2.2: 56 data bytes, press CTRL_C to break
Reply from 192.168.2.2: bytes=56 Sequence=1 ttl=254 time=60 ms
Reply from 192.168.2.2: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 192.168.2.2: bytes=56 Sequence=3 ttl=254 time=80 ms
Reply from 192.168.2.2: bytes=56 Sequence=4 ttl=254 time=60 ms
Reply from 192.168.2.2: bytes=56 Sequence=5 ttl=254 time=50 ms
--- 192.168.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/56/80 ms

可以看到,已经能ping通了,说明配置没有问题。
再来看一下OSPF状态信息:

<R1>dis ospf peer brief
OSPF Process 1 with Router ID 192.168.1.1
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 Ethernet0/0/0 192.168.1.2 Full
----------------------------------------------------------------------------
posted @   顾北清  阅读(555)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
点击右上角即可分享
微信分享提示