zzzzy09

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

在末尾我会放GRE 的配置,在这个测试中我是讲gre 隧道放到内网的GRE 节点来做,所以在 CE 上做了 静态 NAT 配置

 

 

 

来看数据包:

IP 协议承载 GRE 协议, GRE 封装 IP  协议  ,ip 协议承载 icmp 数据包。 在这个截图中src 100.0.0.2 是CE NAT 后的地址,两边要协商好映射关系

 

 

 

开启keeplive 检测功能:

 我在右侧   GRE 设备开启  keeplive  period 3 功能

[~HUAWEI-Tunnel1]dis th
#
interface Tunnel1
 ip address 55.1.1.2 255.255.255.0
 tunnel-protocol gre
 keepalive period 3 
 source 23.0.0.1
 destination 100.0.0.2
#
return
[~HUAWEI-Tunnel1]

 

但是端口立即就 down 了 ,在左侧数据包如下:

左侧配置,为了尽可能分析 两边得source 都是23.0.0.1 

#
interface Tunnel1
 ip address 55.1.1.1 255.255.255.0
 tunnel-protocol gre
 source 23.0.0.1
 destination 220.0.0.2
#

 

 

 

 这里看 IP   报文和  GRE 封装后的 IP 报文报文不对称,所有这里没有进行响应。如果收到的GRE 报文 源是23.0.0.1 目的 220.0.0.2 才是一个正常的,但是我们在CE 做了公网和私网地址转换。

 

看一个正常的报文:

1.1.1.1 开启了 keeplive ,他的探测是构造一个 src  和  dst 相反的 IP 报文承载 keeplive 数据,当 1.1.1.2 收到数据解封装gre 看到ip 报文 src 是tunnel 定义的 source 目的地址是dst 地址因此正常响应。

 

 

 响应数据包

 

 

 在抓包时看最底层的 ip报文的 源和目的地址。

 

总结:

  私网配置GRE 没问题,协商好两端映射地址就行,但是配置 keeplive 就会失败。因此你在所有看到的教材里都是直接公网地址GRE 点对点隧道。避免 keeplive 问题。

 

配置:

GRE1

vlan batch 10 20
interface Vlanif10
 ip address 10.0.0.254 255.255.255.0
#
interface Vlanif20
 ip address 23.0.0.1 255.255.255.0
#
interface MEth0/0/0
 undo shutdown
#
interface GE1/0/0
 undo shutdown
 port default vlan 10
#
interface GE1/0/1
 undo shutdown
 port default vlan 20
#

  interface Tunnel1
  ip address 55.1.1.1 255.255.255.0
  tunnel-protocol gre
  source 23.0.0.1
  destination 220.0.0.2
  #
  interface NULL0
  #
  ip route-static 0.0.0.0 0.0.0.0 23.0.0.254
  ip route-static 20.0.0.0 255.255.255.0 Tunnel1

 

 

CE1

interface GigabitEthernet0/0/0
 ip address 100.0.0.1 255.255.255.0 
 nat static global 100.0.0.2 inside 23.0.0.1 netmask 255.255.255.255
#
interface GigabitEthernet0/0/1
 ip address 23.0.0.254 255.255.255.0 

 

 

GRE2

[~HUAWEI-Tunnel1]dis th
#
interface Tunnel1
 ip address 55.1.1.2 255.255.255.0
 tunnel-protocol gre
 keepalive period 3 
 source 23.0.0.1
 destination 100.0.0.2
#
return
[~HUAWEI-Tunnel1]dis th
#
interface Tunnel1
 ip address 55.1.1.2 255.255.255.0
 tunnel-protocol gre
 keepalive period 3 
 source 23.0.0.1
 destination 100.0.0.2
#
return

 

CE2

interface GigabitEthernet0/0/0
 ip address 220.0.0.254 255.255.255.0 
 nat static global 220.0.0.2 inside 23.0.0.1 netmask 255.255.255.255
#
interface GigabitEthernet0/0/1
 ip address 23.0.0.254 255.255.255.0 

 

 

华为官网:

https://support.huawei.com/enterprise/zh/doc/EDOC1100213140/78a58c99

官方要求两端互为备份

两端Tunnel是否配置了IP地址、源地址(或源接口)和目的地址;两端是否互为源地址(或源接口)和目的地址

 

确定Tunnel两端封装模式一致后,检查两端的Tunnel是否配置了Tunnel的IP地址、源地址(或源接口)和目的地址,重点检查两端的Tunnel是否互为源和目的地址。Tunnel的源地址(或源接口)与目的地址唯一标识了一条隧道;如果不是互为源和目的地址,则就不能共同建立一条隧道。

 

posted on 2021-12-31 11:44  zzzzy09  阅读(697)  评论(0编辑  收藏  举报