GRE的概述
GRE(Generic Routing Encapsulation,通用路由封装)协议是对某些网络层协议(IPX, AppleTalk, IP, IPSec, DVMRP, etc.)的数据报文进行封装,使这些被封装的数据报文能够在另一个网络层协议(如IP)中传输。GRE采用了Tunnel(隧道)技术,是VPN(Virtual Private Network)的第三层隧道协议。
简单理解就是在公网开辟一条虚拟通道给两个不相邻的局域网提供通信服务
配置过程
网络拓扑图
IP地址以及公网互通自行配置,以下只展示GRE隧道的配置方法
公网互通打默认路由即可
例如:[AR2]ip route-static 0.0.0.0 0 12.1.1.2
AR2的配置
[AR2]int Tunnel 0/0/0 进入隧道虚拟机接口
[AR2-Tunnel0/0/0]ip address 192.168.100.10 24 配置IP地址
[AR2-Tunnel0/0/0]tunnel-protocol gre 配置模式为gre
[AR2-Tunnel0/0/0]source 12.1.1.1 配置本地路由器出口地址
[AR2-Tunnel0/0/0]destination 13.1.1.1 配置对端路由器出口地址
[AR2]ip route-static 192.168.2.0 24 192.168.100.20 配置静态路由
AR3的配置
[AR3]int Tunnel 0/0/0
[AR3-Tunnel0/0/0]ip address 192.168.100.20 24
[AR3-Tunnel0/0/0]tunnel-protocol gre
[AR3-Tunnel0/0/0]source 13.1.1.1
[AR3-Tunnel0/0/0]destination 12.1.1.1
[AR3]ip route-static 192.168.1.0 24 192.168.100.10
查看Tunnel的状态
[AR2]dis int Tunnel 0/0/0
Tunnel0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2021-03-13 16:38:01 UTC-08:00
Description:HUAWEI, AR Series, Tunnel0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.100.10/24
Encapsulation is TUNNEL, loopback not set
Tunnel source 12.1.1.1 (GigabitEthernet0/0/0), destination 13.1.1.1
Tunnel protocol/transport GRE/IP, key disabled
keepalive disabled
................
连通测试
抓包验证