大网数据广告活动
服务器运维问答

strongSwan client does not retry connecting to VPN server after the server has rebooted

· 52CE 我爱测

Here’s my current ipsec.conf . What do I need to change to make sure the client retries connecting to server indefinitely. $ cat /etc/ipsec.conf conn %default ike=aes256gcm16-sha384-modp3072! esp=aes256gcm16-sha384-modp3072! conn…

问题原文

原帖链接 · sunknudsen · CC BY-SA 4.0

Here’s my current ipsec.conf.

What do I need to change to make sure the client retries connecting to server indefinitely.

$ cat /etc/ipsec.conf

conn %default
    ike=aes256gcm16-sha384-modp3072!
    esp=aes256gcm16-sha384-modp3072!

conn ikev2
    auto=start
    dpdaction=restart
    closeaction=restart
    keyingtries=%forever
    leftid=[email omitted]
    leftsourceip=%config
    leftauth=eap-tls
    leftcert=vpn-client.crt
    right=159.203.26.109
    rightid=my-vpn.com
    rightsubnet=0.0.0.0/0
    rightauth=pubkey

已采纳解答

原帖链接 · sunknudsen · CC BY-SA 4.0

The following strategy makes sure the connection is always established.

$ vi /usr/local/sbin/monitor.sh
#!/bin/bash

if ipsec status | grep --quiet ESTABLISHED
then
  echo "strongSwan connection is established"
else
  echo "strongSwan connection is not established, restarting..."
  ipsec restart
fi

$ chmod +x /usr/local/sbin/monitor.sh

$ vi /etc/crontab
* * * * * root /usr/local/sbin/monitor.sh > /dev/null 2>&1 &

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-05-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。