GRE,MGRE,ospf

本文深入探讨了网络隧道技术,包括GRE(通用路由封装)和MGRE(多点GRE),以及它们在私网通信中的应用。介绍了NHRP协议在解决私网地址映射中的作用。此外,还详细阐述了OSPF(开放式最短路径优先)协议的特点,如快速收敛和良好的选路性能,以及RIP(路由信息协议)与OSPF的相似点和区别。文章通过实例展示了OSPF的状态机和工作过程,帮助读者理解路由协议的工作原理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GRE,MGRE
NAT技术可以实现私网到私网
在这里插入图片描述
物理专线—1,成本2,地理位置限制

VPN-----虚拟专用网
VPN技术核心-----隧道技术-----封装技术

GRE----通用路由封装

在这里插入图片描述
我们希望的走法:
SIP:1923.168.1.1 DIP:192.168.2.1数据(不经过公网)
但真实走法:
SIP:12.0.0.1DIP23.0.0.2数据

SIP:12.0.0.1 DIP:23.0.0.2 GRE SIP:192.168.1.1 DIP:192.168.2.1

隧道技术—在隧道的两端通过封装

[r1]interface Tunnel 0/0/0  // 创建隧道接口
[r1-Tunnel0/0/0]ip add 192.168.3.1 24  //接口配置ip地址
//定义封装方式
[r1-Tunnel0/0/0]tunnel-protocol gre
//定义封装内容
[r1-Tunnel0/0/0]source 12.0.0.1
[r1-Tunnel0/0/0]description 23.0.0.2

NHRP-----下一跳解析协议----NHS-----下一跳解析服务器–原理:需要在私网中选择一个出口物理地址固定设备作为NHS,剩下的所有分支都应该知道中心的隧道地址和物理地址,然后,NHRP要求所有分支将自己的物理接口和隧道接口的ip地址的映射关系发送给NHS,如果物理地址去发生变化,则需要重新发送。这样NHS可以获取到所有分支的地址的映射关系。分支之间如果需要相互通信,则需要像中心申请获取映射关系表—这种架构我们称hub - spoke架构。
MGRE的配置

ospfv3 — IPV6
RIPV2和OSPFV2的相同点:
1,RIPV2 (224.0.0.9) 和ospfv2 (224.0.0.5, 224.0.0.6)都是以组播的
形式发送信息的。---- 224.0.0.X的组播地址—本地链路组播----
TTL设置为1.
2, RIPV2和OSPFV2都被称为无类别的路由协议。
3,OSPFV2和RIPV2都支持手工认证

在这里插入图片描述

[r1]interface Tunnel 0/0/0  // 创建隧道接口
[r1-Tunnel0/0/0]ip add 192.168.3.1 24  //接口配置ip地址
[r1-Tunnel0/0/0]tunnel-protocol gre p2mp//定义封装方式
//定义封装内容
[r2-Tunnel0/0/0]source GigabitEthernet0/0/1 
//加入到中心创建的NHRP
[r2-Tunnel0/0/0]nhrp network-id 100
//上报信息中心
[r2-Tunnel0/0/0]nhrp entry 192.168.5.1 15.0.0.1 register
隧道地址物理接口地址
[r1-Tunnel0/0/0]display nhrp peer all --- 查看NHRP邻居的注册情况

MGRP环境在数据发送时,依旧是走的点到点的隧道,所以在数据传
输时依然是点到点的传输。所以,MGRE环境是-个类似于NBMA的环境
RIP实现MGRE环境遇到的问题:
1,只有中心获取到了分支的路由信息,而分支没有获取到在中心上开启伪广播
[r1-Tunnel0/0/0]nhrp entry multicast dynamic
2,中心开启伪广播后,分支只能收到中心的路由信息,但没有分支的
原因— RIP的水平分割机制
解决方法: [r1-Tunnel0/0/0]undo rip split-horizon —关闭RIP的水
平分割
OSPF — 开放式最短路径优先协议
选路佳,收敛快,占用资源少
RIP的版本— RIPV1, RIPV2 — IPV4
RIPNG — IPV6
OSPF的版本— ospfv1(实验室阶段天折), ospfv2 — IPV4
ospf—开放式最短路劲优先协议

选路佳,收敛快,占用资源少

RIP的版本----RIPV1,RIPV2,RIPV2-----IPV4
RIPNG—IPV6
OSPF的版本----ospfv1(实验室阶段夭折),ospfv2—ipv4
ospfv3 ----ipv6
ripv2和ospfv2的相同点:

1.ripv2(224.0.0.9)和ospfv2(224.0.0.5 224.0.0.6)都是以组播的形式发送看过信息的。----224.0.0写的组播地址----本地链路组播—TTL设置位1
2,ripv2和ospfv2都被称为无类别的路由协议。
3, ripv2和ospfv2都支持手工认证
4,ripv2和ospfv2都支持开销负载均衡

RIP和OSPF的区别:
RIP只能只能应用在小型网络中,OSPF可以用在中大型网络中—ospf支持结构部署–区域划分—目的–区域内部传递拓扑信息,区域之间传递路由信息。

区域边界路由器----ABR—同时属于两个区域,一个接口对应一个区域

区域划分要求----1,区域之间必须存在ABR设备2,区域划分必须按照星型拓扑划分—星型拓扑中间区域我们称为骨干区域。
区域ID(area ID)----区分和标定ospf网络中不同的区域-----32位二进制构成—
1,点分十进制表示2,直接使用十进制表示----骨干区域的ID定义为区域0

1, OSPF的数据包
hello包—周期发现,建立和保活邻居关系
hello时间— 10S (30S)
Dead time — 4倍的hello时间
RID—1,全网唯一; 2,格式统- —必须按照IP地址的格
式来设计,由32位二进制构成。
1,手工配置—仅需满足以上两个条件即可
2,自动生成—1,先看设备是否配置环回接口,如果存在则选择环回接口的IP地址作为RID;如果存在多个环回接口,则将选择其中数值最大的作为RID。
2,如果不存在环回接口,则将取设备的物理接口IP地
址作为RID,如果存在多个物理接口,则将选择其中数值最大的作为RID。
DBD包—数据库描述报文— LSDB (链路状态数库) ----
LSA —链路状态通告
LSR包—链路状态请求报文—根据DBD包的比对基于本地末
知的L SA信息发出请求。
LSU包—链路状态更新报文—真正携带L SA信息的数据包
LSAck包—链路状态确认报文
OSPF存在30min-次的周期更新。
2,ospf的状态机
在这里插入图片描述
TWO-WAY—标志着邻居关系的建立
(条件匹配)匹配成功则可以进入下一个状态,如果失败,则停留在邻居关系
在这里插入图片描述
主从关系选择------通过比较RID来经行比较RID来进行,RID大的为主,为主的可以有先进入到下一个状态—这里使用DBD包
在这里插入图片描述
FULL状态—标志邻接关系的建立。----目的是为了和邻居状态进行区分。邻居状态只能使用hello包进行周期保活,而邻接状态才能收发LSA信息

down状态— 启动ospf之后,发出hello包之 后进入到下一个状态
init (初始化)状态—收到Hello包中包含本地的RID,则进入到下一一个状态
Two-way (双向通信)状态—标志着邻居关系的建立
(条件匹配)匹配失败,则将停留在邻居关系,仅使用Hello包进行周期保活;匹配
成功则进入下一个状态
exstart(预启动)状态----使用未携带数据的DBD包进行主从关系选择,RID大的为主 ,为主优先进入下一个状态
exchange(准交换)状态—使用携带目录信息的DBD包进行目录共享
loading (加载) 状态—基于对端发送的DBD包,使用LSR/LSU/LSACK三种数据包
获取未知LSA信息。
FULL状态—标志着邻接关系的建立。
3,ospf的工作过程
3,OSPF的工作过程
启动配置完成后,ospf将向本地所有运行协议的接口以组播224.0.0.5的形式发送hello包; hello包中会携带自己本地的RID和本地已知邻居的RID;之后,将收集到的邻居关系记录在本地的一-张表中—邻居表。邻居关系建立完成之后,将进行条件匹配。失败,则停留在邻居关系,仅使用hello包进行周期保活;
匹配成功则开始建立邻接关系。首先,使用未携带数据的DBD包进行主从关系选举,之后,使用携带信息的DBD包共享数据库目录信息。之后,本地使用
LSR/LSU/LSACK三种数据包获取未知的LSA信息。之后,完成本地数据库的建立,生成数据库表— LSDB。
最后,基于本地链路状态数据库中的LSA信息,生成有向图即最短路劲树,之后,计算出本地到达位置网段的路由信息,将这些信息添加到—路由表
收敛完成后,ospf依然会每隔10s(30s)发送hello包进行周期保活;每隔30MIN进行一次周期更新

结构突变情况
1,新增一个网段—触发更新,第一时间将变更信息通过lsu包传递出去,需要ACK确认
2,无法通信
3,断开一个网段
4,ospf的基础配置
在这里插入图片描述

1.启动ospf进程
[r1]ospf 1 router-id 1.1.1.1
2,创建区域
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]
3宣告---激活接口,发布路由
[r1-ospf-1-area-0.0.0.0]network 12.0.0.1 0.0.0.0----反掩码(由连续的0和连续的1组成,0对应不可变,1表示可变----可以进行精准宣告,可以进行范围宣告
[r1]disp ospf peer ----查看邻居关系简表
[r1]dis ospf lsdb---查看数据库表
[r1]dis ospf lsdb router 2.2.2.2 ----展开一条lsa信息
[r1-ospf-1]bandwidth-reference 1000---修改参考带宽需要所有ospf网络中的所有设备都改成相同的。

cost=参考带宽/真实带宽–华为设备默认的参考带宽为100mbps—开销值如果是小于1的小数,则直接按照1来算,如果大于1的小数,直接取正数部分
华为设备定义ospf协议默认优先级为–10

### OSPF Point-to-Multipoint Configuration with MGRE Tunneling Explanation and Setup Guide #### Understanding the Basics of OSPF Point-to-Multipoint Networks In a point-to-multipoint network type within OSPF, routers do not elect Designated Routers (DRs) or Backup Designated Routers (BDRs). Neighbors are established directly between endpoints. The default Hello interval is set to 30 seconds while the Dead interval stands at 120 seconds[^1]. This configuration simplifies neighbor establishment but requires careful planning when integrating advanced features like Multi-Point GRE tunnels. #### Introduction to Multi-Point GRE Tunnels Multi-Point GRE (mGRE) allows multiple remote sites to connect through a single virtual interface on an endpoint device without requiring individual physical interfaces for each connection. mGRE can significantly reduce complexity in hub-and-spoke topologies by enabling dynamic tunnel creation based on IPsec policies or other criteria. #### Combining OSPF Point-to-Multipoint Network Type with mGRE When combining these two technologies: - **Hub Router**: Configured as both ends of all spokes' mGRE sessions. - **Spoke Routers**: Each configured individually pointing back towards the central hub router's public address over which they will establish their respective mGRE session(s). The combination leverages OSPF’s ability to form adjacencies easily across non-broadcast multi-access networks such as those created via mGRE tunnels. It also benefits from OSPF's inherent support for point-to-multipoint configurations where DR/BDR elections aren't necessary due to direct adjacency formation among participating nodes. #### Example Configuration Steps for Hub Router Using Huawei CLI Syntax Below demonstrates how one might configure this scenario using commands similar to what would be found in a typical enterprise-grade environment provided by vendors like Huawei. ```shell # Enter system view mode system-view # Create loopback interface used for establishing mGRE connections interface LoopBack0 ip address 192.168.1.1 255.255.255.255 # Configure real Ethernet port that connects outside world interface GigabitEthernet0/0/1 ip address dhcp # Define mGRE template tunnel-template gre multipoint name mgre-tpl source-interface LoopBack0 destination any # Apply mGRE settings onto actual tunnel interface interface Tunnel0 undo ip address tunnel-protocol gre multipoint apply tunnel-template mgre-tpl ospf enable area 0 ``` For spoke routers, replace `source-interface` command under `tunnel-template` section accordingly depending upon local addressing scheme; ensure consistency throughout entire deployment regarding naming conventions applied here too. #### Verification Commands After Setup Completion Once completed successfully, verify operation status utilizing following instructions available inside most modern networking gear including models produced by companies mentioned earlier: ```shell display ospf peer brief # Check current state of OSPF peers display ip routing-table # Review learned routes after convergence has occurred ping -a <Source_IP> <Destination_IP> # Test reachability between different segments involved ``` --related questions-- 1. How does changing OSPF hello/dead timers affect stability in large-scale deployments? 2. What considerations should administrators take into account before implementing mGRE solutions? 3. Can you explain more about configuring OSPF route-id specifically for devices running OSPF protocol? 4. In what scenarios could deploying OSPF stub areas improve performance compared against standard ones?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值