首页 > 解决方案 > 使用 Strongswan 在 GCP 上的站点到站点 VPN

问题描述

我通过参考https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ikev2-vpn-server-with-strongswan-on在 GCP 计算引擎(Ubuntu 20.04)上安装了 strongswan VPN -ubuntu-20-04

有 3 个不同的项目,我从 Strongswan VPN 计算引擎为所有人设置了一条隧道。

下面是 ipsec.conf 文件

conn strongswan-to-ops
    ikelifetime=600m # 36,000 s
    keylife=180m # 10,800 s
    rekeymargin=3m
    keyingtries=3
    keyexchange=ikev2
    mobike=no
    ike=chacha20poly1305-sha512-curve25519-prfsha512,aes256gcm16-sha384-prfsha384-ecp384,aes256-sha1-modp1024,aes128-sha1-modp1024,3des-sha1-modp1024!
    esp=chacha20poly1305-sha512,aes256gcm16-ecp384,aes256-sha256,aes256-sha1,3des-sha1!
    authby=psk
    left=172.x.x.x # In case of NAT set to internal IP, e.x. 10.164.0.6
    leftid=172.x.x.x
    leftsubnet=192.x.x.x/24
    leftauth=psk
    right=[gateway IP]
    rightid=[gateway IP]
    rightsubnet=172.x.x.x/16
    rightauth=psk
    type=tunnel
    auto=start
    dpdaction=restart

IPsec 状态显示

Security Associations (2 up, 0 connecting):
strongswan-to-ops[4]: ESTABLISHED 46 minutes ago, 
strongswan-to-ops{3}:  INSTALLED, TUNNEL, reqid 2, ESP in UDP SPIs: c233fb9c_i 17261c13_o
strongswan-to-ops{3}:   192.x.x.x/24 === 172.x.x.x/16

但仍然无法访问其他项目上的 HTTP 服务器/其他 VM

标签: google-cloud-platformvpntunnelingipsecstrongswan

解决方案


在 GCP 计算引擎上,IP 转发已关闭,所以这就是问题所在。

我拍摄了 Compute Engine 的快照并使用它创建新的,并将 IP 转发标记为 ON。


推荐阅读