• GRE 隧道深入分析


    在末尾我会放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的源地址(或源接口)与目的地址唯一标识了一条隧道;如果不是互为源和目的地址,则就不能共同建立一条隧道。

  • 相关阅读:
    将Python的Django框架与认证系统整合的方法
    将Python的Django框架与认证系统整合的方法
    Python的Asyncore异步Socket模块及实现端口转发的例子
    每天一个linux命令(3):du命令
    每天一个linux命令(2):file 命令
    Ubantu 使用extundelete恢复数据
    ubantu 单用户模式进入系统
    GDB 调试解析
    服务器搭建5 Samba实现文件共享
    服务器搭建4 安装其它库
  • 原文地址:https://www.cnblogs.com/zy09/p/15752411.html
Copyright © 2020-2023  润新知