这是我现在的ipsec.conf
。
我需要做哪些更改才能确保客户端无限期地重试连接服务器。
$ cat /etc/ipsec.conf
conn %default
ike=aes256gcm16-sha384-modp3072!
esp=aes256gcm16-sha384-modp3072!
conn ikev2
auto=start
dpdaction=restart
closeaction=restart
keyingtries=%forever
[email protected]
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
答案1
以下策略确保始终建立连接。
$ 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 &