Ipsec
strongSwan 客戶端在伺服器重新啟動後不會重試連接到 VPN 伺服器
這是我目前的
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 leftid=client@my-vpn.com 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
以下策略可確保始終建立連接。
$ 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 &