Cisco-OSPF虚链路

简介: Cisco-OSPF虚链路

前言

网络已经成为了我们生活中不可或缺的一部分,它连接了世界各地的人们,让信息和资源得以自由流动。随着互联网的发展,我们可以通过网络学习、工作、娱乐,甚至是社交。因此,学习网络知识和技能已经成为了每个人都需要掌握的重要能力。

本课程博主将带领读者深入了解网络的基本原理、结构和运作方式,帮助读者建立起对网络的全面理解。我们将介绍网络的发展历程、网络的分类和组成、网络的安全和隐私保护等内容,帮助读者掌握网络知识,提高网络素养。

通过学习本篇博客,读者将能够更好地利用网络资源,提高工作效率,拓展人际关系,甚至是保护自己的网络安全。网络世界充满了无限的可能,希望本课程能够帮助读者更好地驾驭网络,享受网络带来的便利和乐趣。


一、什么是OSPF虚链路?

在OSPF(开放式最短路径优先)协议中,虚链路是一种特殊的链路,用于连接不能直接通信的两个不同自治系统(AS)。虚链路允许在不改变现有网络拓扑的情况下,OSPF路由器能够跨越多个AS通告路由信息。

在配置虚链路时,需要指定一个虚链路的传输接口,并为该接口指定一个虚拟的网络号(IP地址),这个IP地址将作为目的AS内的一个路由器的直接连接接口的IP地址。


二、实验

1.引入

实验目标

理解OSPF虚链路的原理及功能;

掌握OSPF虚链路的配置方法;

实验背景

你是某公司的网络管理员,公司现在扩展业务,在保证原有网络拓扑的情况下添加新业务(人事部),现在请你帮忙想办法实验这个功能,

一楼是公司总部,二楼是公司业务部,三楼是公司办公室,四楼是公司人事部

技术原理

虚链路技术是Open Shortest Path First (OSPF)路由协议中的一个特性,它允许在不改变网络拓扑的情况下,将一个路由器虚拟接入到另一个区域。

虚链路的工作原理是:在区域边界路由器(ABR)上配置一个目标区域和一个传输区域,ABR会创建一个虚拟接口,用于在这两个区域之间传递路由信息。

实验步骤

新建Packet Tracer拓扑图

(1)公司中的两台路由器与交换机连接,与外网的路由器连接并进行配置公网IP

(2)配置路由器接口IP地址。

(3)验证主机之间的互通性。

实验设备

Route 2811 4台 ,交叉线

实验拓扑图

实验配置

R1,R2,R3,R4基础配置

R1:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h R1
R1(config)#int f0/0
R1(config-if)#ip add 10.0.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#route ospf 10
R1(config-router)#net 10.0.1.0 0.0.0.255 area 0
 
R2:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h R2
R2(config)#int f0/0
R2(config-if)#ip add 10.0.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int f0/1
R2(config-if)#ip add 10.0.2.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#route ospf 10
R2(config-router)#net 10.0.1.0 0.0.0.255 area 0
R2(config-router)#net 10.0.2.0 0.0.0.255 area 1
 
R3:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h R3
R3(config)#int f0/0
R3(config-if)#ip add 10.0.2.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#int f0/1
R3(config-if)#ip add 10.0.3.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#route ospf 10
R3(config-router)#net 10.0.3.0 0.0.0.255 area 2
R3(config-router)#net 10.0.2.0 0.0.0.255 area 1
 
R4:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h R4
R4(config)#int f0/0
R4(config-if)#ip add 10.0.3.2 255.255.255.0
R4(config-if)#no shut
R4(config-if)#exit
R4(config)#route ospf 10
R4(config-router)#net 10.0.3.0 0.0.0.255 area 2

show ip route R1,R2,R3,R4

R1:
R1(config-router)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
C       10.0.1.0/24 is directly connected, FastEthernet0/0
L       10.0.1.1/32 is directly connected, FastEthernet0/0
O IA    10.0.2.0/24 [110/2] via 10.0.1.2, 00:03:01, FastEthernet0/0
 
R2:
R2(config-if)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C       10.0.1.0/24 is directly connected, FastEthernet0/0
L       10.0.1.2/32 is directly connected, FastEthernet0/0
C       10.0.2.0/24 is directly connected, FastEthernet0/1
L       10.0.2.1/32 is directly connected, FastEthernet0/1
 
R3:
R3(config-router)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
O IA    10.0.1.0/24 [110/2] via 10.0.2.1, 00:02:19, FastEthernet0/0
C       10.0.2.0/24 is directly connected, FastEthernet0/0
L       10.0.2.2/32 is directly connected, FastEthernet0/0
C       10.0.3.0/24 is directly connected, FastEthernet0/1
L       10.0.3.1/32 is directly connected, FastEthernet0/1
 
R4(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C       10.0.3.0/24 is directly connected, FastEthernet0/0
L       10.0.3.2/32 is directly connected, FastEthernet0/0
 

可以观察到,R1学不到R3与R4之间的IP,这是因为OSPF中area区域,0是骨干,默认的需要与骨干区域相连才可以学习到相应的IP地址,因此我们引入了OSPF虚链路来帮助我们应对这种问题的发生.

OSPF虚链路的配置

R1:
R1(config)#int loopback 0
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#exit
R1(config-if)#route ospf 10
R1(config-router)#router-id 1.1.1.1
 
R2:
R2(config)#int loopback 0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#exit
R2(config)#route ospf 10
R2(config-router)#router-id 2.2.2.2
R2(config-router)#area 1 virtual-link  3.3.3.3
 
R3:
R3(config)#int loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#exit
R3(config)#route ospf 10
R3(config-router)#router-id 3.3.3.3
R3(config-router)#area 1 vir 2.2.2.2
 
R4:
R4(config)#int loopback 0
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#exit
R4(config-if)#route ospf 10
R4(config-router)#router-id 4.4.4.4
 
如果没有学习到在特权模式下使用命令
R1#clear ip os p
Reset ALL OSPF processes? [no]: y

R1 Ping R4

观察到可以ping通了

扩展

你是某公司的网络管理员,公司现在扩展业务,在保证原有网络拓扑的情况下添加新业务(人事部),公司突然宣布五楼要加入财务部,希望再添加一层

一楼是公司总部,二楼是公司业务部,三楼是公司办公室,四楼是公司人事部,五楼是公司财务部

实验拓扑图

实验配置

R4,R5基础配置

R4:
R4(config)#int f0/1
R4(config-if)#ip add 10.0.4.1 255.255.255.0
R4(config-if)#exit
R4(config)#route ospf 10
R4(config-router)#net 10.0.4.0 0.0.0.255 area 3
 
R5:
Router>en
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#h R5
R5(config)#int f0/0
R5(config-if)#no shut
R5(config-if)#ip add 10.0.4.0 255.255.255.0
R5(config-if)#exit
R5(config)#int l 0
R5(config-if)#ip add 5.5.5.5 255.255.255.255
R5(config)#route ospf 10
R5(config-router)#net 10.0.4.0 0.0.0.255 area 3
R5(config-router)#router-id 5.5.5.5

Show ip route R1

R1:
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1/32 is directly connected, Loopback0
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C       10.0.1.0/24 is directly connected, FastEthernet0/0
L       10.0.1.1/32 is directly connected, FastEthernet0/0
O IA    10.0.2.0/24 [110/2] via 10.0.1.2, 00:13:53, FastEthernet0/0
O IA    10.0.3.0/24 [110/3] via 10.0.1.2, 00:13:43, FastEthernet0/0
O IA    10.0.4.0/24 [110/4] via 10.0.1.2, 00:00:11, FastEthernet0/0

OSPF虚链路的配置

R3:
R3(config)#router ospf 10
R3(config-router)#area 2 vir 4.4.4.4
 
R4:
R4(config)#route ospf 10
R4(config-router)#area 2 vir 3.3.3.3

实验验证

R1 Ping R5


相关文章
|
应用服务中间件 nginx
利用nginx+fancyindex美化目录索引
利用nginx+fancyindex美化目录索引 1.下载第三方插件
1387 0
利用nginx+fancyindex美化目录索引
|
Web App开发 Cloud Native Docker
删除容器报错:Error response from daemon: conflict: unable to delete
云原生日益普及的现在,docker容器化成为现有很多服务的改进方向,docker凭借更高效的利用系统资源、更快速的启动时间、一致的运行环境、持续支付和部署、更轻松的迁移、更轻松的维护和拓展等优势,迅速走红。但是,很多容器部署后在回收时,都会遇到各种各样的问题,比如今天讨论的删除镜像的问题,有时候删除操作会莫名其妙的报错。
1459 1
|
7月前
|
人工智能 Linux API
Hermes Agent 从零到精通:安装优化、阿里云百炼模型配置、工具启用一站式指南
Hermes Agent 是 Nous Research 在 2026 年初发布的开源自主进化 AI 智能体框架,基于 MIT 开源协议、采用 Python 构建,最新版本为 v0.13.0。它与普通对话式 AI 不同,具备**任务沉淀、技能学习、持久记忆、多工具并行**等能力,能够在不断使用中自我进化,越用越强。
940 4
|
前端开发 JavaScript Java
基于springboot+vue开发的校园食堂评价系统【源码+sql+可运行】【50809】
本系统基于SpringBoot与Vue3开发,实现校园食堂评价功能。前台支持用户注册登录、食堂浏览、菜品查看及评价发布;后台提供食堂、菜品与评价管理模块,支持权限控制与数据维护。技术栈涵盖SpringBoot、MyBatisPlus、Vue3、ElementUI等,适配响应式布局,提供完整源码与数据库脚本,可直接运行部署。
761 6
基于springboot+vue开发的校园食堂评价系统【源码+sql+可运行】【50809】
|
7月前
|
存储 人工智能 数据处理
RAG 落地三部曲:用 Milvus + Qwen3.6 打造企业知识库,我踩过的 5 个坑与解法
本文揭秘RAG落地常见误区:文档粗暴切片、纯向量检索、忽略重排序导致知识库“很蠢”。基于阿里云Milvus+百炼Qwen3.6,详解轻量部署、结构化分片、混合检索(向量+全文)、GTE-Rerank重排序及防幻觉Prompt工程,并给出Embedding成本优化策略。(239字)
|
6月前
|
供应链 前端开发 API
跨境电商 Shopify 的 API 对接
本文详解Shopify跨境API对接开发:聚焦GraphQL-First架构,涵盖Admin/Storefront双API选型、OAuth认证、精准GraphQL查询与幂等变更、实时Webhook事件驱动(含合规三类钩子)、成本制限流应对,以及多仓库存、跨境报关、物流履约、多币种结汇四大核心场景,附官方SDK与GraphiQL实践建议。(239字)
|
8月前
|
人工智能 自然语言处理 安全
JeecgBoot v3.9.2 王炸升级|低代码迈入 v2.0 时代,告别拖拉拽,Skills 加持一句话搭建系统
JeecgBoot AI专题研究 v3.9.2 主版本发布 + Skills 独立仓库 + Online 三件套大优化项目介绍AI Skills 自然语言编程全新发布: 一句话生成完整代码、一句话画流程、一句话设计表单、一句话出报表与大屏、一句话生成整个系统,覆盖 JeecgBoot 低代码全
704 2
|
10月前
|
Python
抖音弹幕游戏开发之第11集:礼物触发功能·优雅草云桧·卓伊凡
《抖音弹幕游戏开发专栏》由优雅草云桂主讲、卓伊凡辅助,第11集详解礼物触发功能:解析giftName等核心字段,设计玫瑰摇摆、爱心跳跃、火箭旋转等规则,并用Python实现带次数限制的实时交互效果。
521 11
|
9月前
|
机器学习/深度学习 人工智能 计算机视觉
从寒冬到盛夏——AI发展简史
1956年的夏天,美国达特茅斯学院的一间会议室里,一群年轻的科学家聚在一起,讨论着一个当时听起来近乎疯狂的想法:能不能让机器像人一样思考?这场持续八周的会议,后来被公认为人工智能的诞生之地。
704 4
|
11月前
|
安全 数据可视化 物联网
智慧工地人员定位系统从核心技术对比到技术优势详解(一)
智慧工地人员定位系统融合UWB、北斗、蓝牙等多源技术,实现室内外厘米级至米级精准定位,支持三维可视化、AR导航与工业级防护,兼顾安全管控、效率提升与复杂场景适配。如果您想进一步了解人员定位的案例,欢迎关注、评论留言~也可搜索维构lbs智能定位。