使用ensp模拟GRE(通用路由封装)

GRE(Generic Routing Encapsulation, 通用路由封装) 是一种简单的隧道协议,用于在IP网络中封装多种协议的数据包。封装后的格式为:外层ip头GER 头内层数据(包含内层ip)

实验过程和目的

在AR1 和 AR3 建立 GRE 隧道

基础配置,保证ospf 正常运行,pc1和pc2可以获取地址

#AR1

system-view
sysname AR1
undo info-center enable

dhcp enable

ospf 1 router-id 1.1.1.1
area 0
quit

int g0/0/0
ip address 12.0.0.1 24
ospf enable area 0
quit

int g0/0/1
ip address 192.168.10.1 24
dhcp select interface
#AR2

system-view
sysname AR2
undo info-center enable


ospf 1 router-id 2.2.2.2
area 0
quit

int g0/0/1
ip address 23.0.0.2 24
ospf enable area 0

int g0/0/0
ip address 12.0.0.2 24
quit
#AR3

system-view
sysname AR3
undo info-center enable

dhcp enable

ospf  1 router-id 3.3.3.3
area 0
quit

int g0/0/1
ip address 192.168.20.1 24
dhcp select interface
ospf enable area 0

int g0/0/0
ip address 23.0.0.3 24
ospf enable area 0
quit

GRE 配置

#AR1

interface Tunnel0/0/0
 ip address 10.0.0.1 255.255.255.252 
 tunnel-protocol gre
 keepalive
 source 12.0.0.1
 destination 23.0.0.3
 gre key 1
 gre checksum

quit

ip route-static 192.168.20.0 24 Tunnel 0/0/0
#AR3

interface Tunnel0/0/0
 ip address 10.0.0.2 255.255.255.252 
 tunnel-protocol gre
 keepalive
 source 23.0.0.3
 destination 12.0.0.1
 gre key 1
 gre checksum

quit

ip route-static 192.168.10.0 24 Tunnel 0/0/0

需要注意的地方

  1. keepalive interval 5 retry-times 3 # 5秒间隔,3次重试 (启用 GRE 隧道保活机制,默认每 10 秒发送一次探测报文,超时 3 次后置隧道为 Down。)
  2. 最后要加上路由,指定目的地址那些网段走隧道。
  3. gre key 1 两端的密钥要一致
[AR1-Tunnel0/0/0]gre key ?
  INTEGER<0-4294967295>  Tunnel key Value

实验拓扑图

gre下载