How I got OpenVPN to work on Ubuntu 18.04LTS after sleep/suspend

published May 10, 2018 04:35   by admin ( last modified May 12, 2018 03:07 )

These are preliminary results, it seems to work.

Summary

Switch in the update-resolv-conf from here https://github.com/masterkorp/openvpn-update-resolv-conf/blob/master/update-resolv-conf.sh

and install openresolv

sudo apt install openresolv
  • reboot

The original update-resolv-conf distributed with the openvpn package in Ubuntu 18.04 did not work for me:

https://packages.ubuntu.com/xenial-updates/openvpn

Or, it could possibly be that openresolv resolved the problem of update-resolv-conf not exiting cleanly. I haven't bothered yet to check which of these two changes made the difference, but I suspect it is update-resolv-conf.

Longer text

I could not get systemd to reliably start OpenVPN, especially not after sleep. Restarting OpenVPN after sleep, through systemd, made OpenVPN work every second time. Every odd time (including time number 1) it complained about the up and down scripts not exiting cleanly:

"WARNING: Failed running command (--up/--down): external program did not exit normally"

I resorted to starting the vpn from the command line, same problem, so systemd is not at fault here.

The new update-resolv-conf script I use has this at the end:

# Workaround / jm@epiclabs.io 
# force exit with no errors. Due to an apparent conflict with the Network Manager
# $RESOLVCONF sometimes exits with error code 6 even though it has performed the
# action correctly and OpenVPN shuts down.
exit 0

Who knows, maybe that is all that was needed?