AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 399961
Accepted
Dan Udey
Dan Udey
Asked: 2012-06-19 15:56:44 +0800 CST2012-06-19 15:56:44 +0800 CST 2012-06-19 15:56:44 +0800 CST

Amazon VPC 和 Linux 服务器之间的 IPSec VPN

  • 772

我正在尝试使用他们的 VPN 系统和 Linux 服务器在我们的公司网络和亚马逊的虚拟私有云之间建立一个 IPSec VPN 连接。不幸的是,我找到的唯一指南讨论了如何使用主机 Linux 机器设置隧道并让该 Linux 机器访问 VPC 实例,但是我没有在网上找到关于如何让实例访问公司网络的讨论(或通过该网络的其余互联网)。

网络信息

Local subnet: 10.3.0.0/25
Remote subnet: 10.4.0.0/16

Tunnel 1:
  Outside IP Addresses:
    - Customer Gateway:        : 199.167.xxx.xxx
    - VPN Gateway              : 205.251.233.121

  Inside IP Addresses
    - Customer Gateway         : 169.254.249.2/30
    - VPN Gateway              : 169.254.249.1/30

Tunnel 2:
  Outside IP Addresses:
    - Customer Gateway:        : 199.167.xxx.xxx
    - VPN Gateway              : 205.251.233.122

  Inside IP Addresses
    - Customer Gateway         : 169.254.249.6/30
    - VPN Gateway              : 169.254.249.5/30

这是我的 /etc/ipsec-tools.conf:

flush;
spdflush;

spdadd 169.254.249.2/30 169.254.249.1/30 any -P out ipsec
   esp/tunnel/199.167.xxx.xxx-205.251.233.121/require;

spdadd 169.254.249.1/30 169.254.249.2/30 any -P in ipsec
   esp/tunnel/205.251.233.121-199.167.xxx.xxx/require;

spdadd 169.254.249.6/30 169.254.249.5/30 any -P out ipsec
   esp/tunnel/199.167.xxx.xxx-205.251.233.122/require;

spdadd 169.254.249.5/30 169.254.249.6/30 any -P in ipsec
   esp/tunnel/205.251.233.122-199.167.xxx.xxx/require;



spdadd 169.254.249.2/30 10.4.0.0/16 any -P out ipsec
   esp/tunnel/199.167.xxx.xxx-205.251.233.121/require;

spdadd 10.4.0.0/16 169.254.249.2/30 any -P in ipsec
   esp/tunnel/205.251.233.121-199.167.xxx.xxx/require;

spdadd 169.254.249.6/30 10.4.0.0/16 any -P out ipsec
   esp/tunnel/199.167.xxx.xxx-205.251.233.122/require;

spdadd 10.4.0.0/16 169.254.249.6/30 any -P in ipsec
   esp/tunnel/205.251.233.122-199.167.xxx.xxx/require;

这是我的 /etc/racoon/racoon.conf:

remote 205.251.233.122 {
        exchange_mode main;
        lifetime time 28800 seconds;
        proposal {
                encryption_algorithm aes128;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
        generate_policy off;
}

remote 205.251.233.121 {
        exchange_mode main;
        lifetime time 28800 seconds;
        proposal {
                encryption_algorithm aes128;
                hash_algorithm sha1;
                authentication_method pre_shared_key;
                dh_group 2;
        }
        generate_policy off;
}

sainfo address 169.254.249.2/30 any address 169.254.249.1/30 any {
    pfs_group 2;
    lifetime time 3600 seconds;
    encryption_algorithm aes128;
    authentication_algorithm hmac_sha1;
    compression_algorithm deflate;
}

sainfo address 169.254.249.6/30 any address 169.254.249.5/30 any {
    pfs_group 2;
    lifetime time 3600 seconds;
    encryption_algorithm aes128;
    authentication_algorithm hmac_sha1;
    compression_algorithm deflate;
}

BGP 工作正常,所以我不打算发布这些配置。

这是有效的

  • 在 Linux 机器上,我可以 ping 通本地端点 (169.254.249.2/169.254.249.6) 及其远程端点 (169.254.249.1/169.254.249.5)。
  • 我还可以 ping VPC 中的实例,通过 SSH 连接到它们,等等。
  • 从 VPC 中的远程实例,我也可以 ping 本地和远程端点
  • 我无法 ping 通 10.3.0.0/25 子网上的本地服务器

我假设我遗漏了一些简单的东西,但我已经尝试将条目添加到 ipsec-tools.conf 以镜像 {local endpoint}<->{remote subnet},使用 {local subnet}<->{remote endpoint},但它似乎没有用。

当我从 {remote instance} ping 到 {local server} 时,ping 超时。这些数据包在 eth0 接口上可见(即使本地网络在 eth1 上)。

谷歌帮助不大;它仅显示尝试使用 OpenSwan 的人,或遇到类似问题但使用硬件路由器或使用旧工具的人。

vpn ipsec amazon-vpc
  • 3 3 个回答
  • 5491 Views

3 个回答

  • Voted
  1. Petter
    2012-06-20T07:17:42+08:002012-06-20T07:17:42+08:00

    好吧,我作弊了 :) 我安装了亚马逊官方支持的 Astaro 网关,然后用它来模拟我自己的网关。您可以通过 SSH 连接到 Astaro 设备,看看他们是如何设置一切的。当然,如果您愿意付费,可以坚持使用 Astaro 设备。

    • 3
  2. Best Answer
    Dan Udey
    2012-06-20T09:42:38+08:002012-06-20T09:42:38+08:00

    弄清楚了。必须将我的 ipsec-tools.conf 更改为:

    flush;
    spdflush;
    
    # Generic routing
    spdadd 10.4.0.0/16 10.3.0.0/25 any -P in  ipsec esp/tunnel/205.251.233.121-199.167.xxx.xxx/require;
    spdadd 10.3.0.0/25 10.4.0.0/16 any -P out ipsec esp/tunnel/199.167.xxx.xxx-205.251.233.121/require;
    
    # Tunnel 1
    spdadd 169.254.249.1/30 169.254.249.2/30 any -P in  ipsec esp/tunnel/205.251.233.121-199.167.xxx.xxx/require;
    spdadd 169.254.249.2/30 169.254.249.1/30 any -P out ipsec esp/tunnel/199.167.xxx.xxx-205.251.233.121/require;
    
    spdadd 10.4.0.0/16 169.254.249.2/30 any -P in  ipsec esp/tunnel/205.251.233.121-199.167.xxx.xxx/require;
    spdadd 169.254.249.2/30 10.4.0.0/16 any -P out ipsec esp/tunnel/199.167.xxx.xxx-205.251.233.121/require;
    
    # Tunnel 2
    spdadd 169.254.249.5/30 169.254.249.6/30 any -P in  ipsec esp/tunnel/205.251.233.122-199.167.xxx.xxx/require;
    spdadd 169.254.249.6/30 169.254.249.5/30 any -P out ipsec esp/tunnel/199.167.xxx.xxx-205.251.233.122/require;
    
    spdadd 10.4.0.0/16 169.254.249.6/30 any -P in  ipsec esp/tunnel/205.251.233.122-199.167.xxx.xxx/require;
    spdadd 169.254.249.6/30 10.4.0.0/16 any -P out ipsec esp/tunnel/199.167.xxx.xxx-205.251.233.122/require;
    

    并将我的 racoon.conf 更改为:

    path pre_shared_key "/etc/racoon/psk.txt";
    
    remote 205.251.233.122 {
            exchange_mode main;
            lifetime time 28800 seconds;
            proposal {
                    encryption_algorithm aes128;
                    hash_algorithm sha1;
                    authentication_method pre_shared_key;
                    dh_group 2;
            }
            generate_policy off;
    }
    
    remote 205.251.233.121 {
            exchange_mode main;
            lifetime time 28800 seconds;
            proposal {
                    encryption_algorithm aes128;
                    hash_algorithm sha1;
                    authentication_method pre_shared_key;
                    dh_group 2;
            }
            generate_policy off;
    }
    
    sainfo address 169.254.249.2/30 any address 169.254.249.1/30 any {
        pfs_group 2;
        lifetime time 3600 seconds;
        encryption_algorithm aes128;
        authentication_algorithm hmac_sha1;
        compression_algorithm deflate;
    }
    
    sainfo address 169.254.249.6/30 any address 169.254.249.5/30 any {
        pfs_group 2;
        lifetime time 3600 seconds;
        encryption_algorithm aes128;
        authentication_algorithm hmac_sha1;
        compression_algorithm deflate;
    }
    
    sainfo address 10.3.0.0/25 any address 10.4.0.0/16 any {
        pfs_group 2;
        lifetime time 3600 seconds;
        encryption_algorithm aes128;
        authentication_algorithm hmac_sha1;
        compression_algorithm deflate;
    }
    

    但是,据我了解,此配置只会通过第一个隧道(通过 xxx121)路由 10.3.0.0/25 和 10.4.0.0/16 之间的流量。当我弄清楚时,我会更新答案。

    • 3
  3. DPfiler
    2019-08-14T08:58:23+08:002019-08-14T08:58:23+08:00

    您知道在 setkey 配置中使用“require”而不是“use”的原因吗?您是否也知道我将语句放在 remote 和 sainfo 部分中的顺序以及错误地复制某些语句是否重要?例如:

    #original
    remote 205.251.233.121 {
            exchange_mode main;
            lifetime time 28800 seconds;
            proposal {
                    encryption_algorithm aes128;
                    hash_algorithm sha1;
                    authentication_method pre_shared_key;
                    dh_group 2;
            }
            generate_policy off;
    }
    

    对比

    #edited
    remote 205.251.233.121 {
            generate_policy off;                           #moved/duplicated
            lifetime time 28800 seconds;
            proposal {
                    dh_group 2;                           #moved
                    encryption_algorithm aes128;
                    hash_algorithm sha1;
                    authentication_method pre_shared_key;
            }
             exchange_mode main;                      #moved
            generate_policy off;                   #duplicated/moved
    }
    

    您是否还弄清楚如何让流量在两条隧道上流动?

    感谢您的指导。

    • 0

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • 用 D-LINK DFL-CPG310 防火墙替换 Cisco Pix 防火墙

  • 最好的点对点 VPN?

  • WAN 上的 VLAN

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve