strongswan

StrongSwan IPsec VPN

补充说明

StrongSwan 是 IPsec/IKEv2 VPN 实现,支持站点到站点、远程接入和证书认证。常用于云上 VPC 互联和混合云。

新旧两套配置:ipsec.conf/ipsec.secrets 和 swanctl.conf/swanctl。新版本推荐 swanctl。

常用示例

安装:

apt install strongswan strongswan-swanctl
systemctl enable --now strongswan

swanctl.conf 示例:

connections {
  net-to-net {
    local_addrs = 203.0.113.1
    remote_addrs = 198.51.100.1
    local { auth = psk; id = 203.0.113.1; }
    remote { auth = psk; id = 198.51.100.1; }
    children {
      net {
        local_ts = 10.1.0.0/24
        remote_ts = 10.2.0.0/24
        esp_proposals = aes256-sha256-modp2048
      }
    }
    version = 2
    proposals = aes256-sha256-modp2048
  }
}
secrets {
  ike-1 { secret = "***"; }
}

加载并查看:

swanctl --load-all
swanctl --list-conns
swanctl --list-sas
swanctl --initiate --child net

易错点与排错