IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    GRE隧道配置

    admin发表于 2017-04-12 08:51:59
    love 0

     

    本篇介绍在两台服务器之间如何操作配置开启GRE隧道:

    一、

    # 服务器A网卡信息:
    inet 199.99.88.77  netmask 255.255.255.0  broadcast 199.99.88.255
    
    # 服务器B网卡信息:
    inet 144.33.22.11  netmask 255.255.255.0  broadcast 144.33.22.255

    二、

    # 分别在A和B服务器开启IP_GRE模块
    
    # 服务器A:
    [root@A ~]# modprobe ip_gre
    [root@A ~]# lsmod | grep gre
    ip_gre                 22843  0 
    ip_tunnel              25163  1 ip_gre
    gre                    12950  1 ip_gre
    
    # 服务器B:
    [root@B ~]# modprobe ip_gre
    [root@B ~]# lsmod | grep gre
    ip_gre                 22843  0 
    ip_tunnel              25163  1 ip_gre
    gre                    12950  1 ip_gre

    三、

    # 服务器A:
    [root@A ~]# ip tunnel add gre1 mode gre remote 144.33.22.11 local 199.99.88.77 ttl 255
    [root@A ~]# ip link set gre1 up
    [root@A ~]# ip addr add 10.10.10.2 peer 10.10.10.3 dev gre1
    
    # 服务器B:
    [root@B ~]# ip tunnel add gre1 mode gre remote  199.99.88.77 local 144.33.22.11 ttl 255
    [root@B ~]# ip link set gre1 up
    [root@B ~]# ip addr add 10.10.10.3 peer 10.10.10.2 dev gre1

    四、

    # 连通性检测
    
    # 服务器A:
    [root@A ~]# ping 10.10.10.3
    PING 10.10.10.3 (10.10.10.3) 56(84) bytes of data.
    64 bytes from 10.10.10.3: icmp_seq=1 ttl=64 time=0.872 ms
    64 bytes from 10.10.10.3: icmp_seq=3 ttl=64 time=0.895 ms
    64 bytes from 10.10.10.3: icmp_seq=4 ttl=64 time=0.884 ms
    
    # 服务器B:
    [root@B ~]# ping 10.10.10.2
    PING 10.10.10.2 (10.10.10.2) 56(84) bytes of data.
    64 bytes from 10.10.10.2: icmp_seq=1 ttl=64 time=0.884 ms
    64 bytes from 10.10.10.2: icmp_seq=2 ttl=64 time=0.830 ms
    64 bytes from 10.10.10.2: icmp_seq=2 ttl=64 time=0.890 ms

    五、

    # 删除GRE隧道
    
    # 服务器A:
    [root@A ~]# ip link set gre1 down
    [root@A ~]# ip tunnel del gre1
    
    # 服务器B:
    [root@B ~]# ip link set gre1 down
    [root@B ~]# ip tunnel del gre1

    六、

    更多参考:

    buyvm提供DDOS服务,通过GRE隧道使用此服务

    http://wiki.buyvm.net/doku.php/gre_tunnel



沪ICP备19023445号-2号
友情链接