I enabled an openvpn globally by
systemctl enable openvpn@con.service
Which works well and I'm connected to my VPN after reboot. But once I suspend my laptop instead of rebooting, or simply lose the connection, I can't access to internet any more and have to do either a reboot or a systemctl restart openvpn@con.service
How can I reconnect automatically to my VPN?
An idea I have is to edit the openvpn@con.service manually and set a Restart=always
and a RestartSec=15
. But is that safe any longer? Won't my connection be interrupted? Is there a better solution?
This is what my con.conf looks like:
client
dev tun0
proto udp
remote pw.openvpn.ipredator.se 1194
resolv-retry infinite
nobind
auth-user-pass /etc/openvpn/IPredator.auth
auth-retry nointeract
ca [inline]
tls-client
tls-auth [inline]
ns-cert-type server
keepalive 10 30
cipher AES-256-CBC
tls-cipher TLSv1:!ADH:!SSLv2:!NULL:!EXPORT:!DES:!LOW:!MEDIUM:@STRENGTH
persist-key
persist-tun
comp-lzo
tun-mtu 1500
mssfix
passtos
verb 3
<ca>
-----BEGIN CERTIFICATE-----
dummy
-----END CERTIFICATE-----
</ca>
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
dummy
-----END OpenVPN Static key V1-----
</tls-auth>
verb 3
.