Stop Ubuntu 14.04 VPN From Dying

The title of my post is a bit misleading, but it’s my solution to the problem. I found that my VPN would randomly die on Ubuntu. I could ping the network internal, but everything external was dead. What I did was add a cron job which checks every minute if the interface is up and if it isn’t, restart the VPN.

Type: sudo crontab -e

Add the line:

* * * * * if !(grep -q <VPN_INTERFACE_NAME> /proc/net/dev); then nmcli con up id <VPN_NAME>; fi

You can check a list of your interface names with nmcli con. The line basically says, check if my VPN is in the list of available interfaces, if it isn’t bring it up.

Hope this helps.

Leave a Reply