OpenVPN breaks default gateway

I've been using OpenVPN on Linux for a while now and it works great! The only problem I've found is that when you stop the OpenVPN service it tears down all the routes associated with that tunnel, including your default route/gateway. That means that after it's stopped you have no Internet access. This appears to be a bug/feature in OpenVPN where it can't rebuild your routes unless the OpenVPN daemon runs as root (which is not recommended). My OpenVPN runs as nobody/nobody and thus when OpenVPN stops it fails trying to add back the default route.

There is a simple work around to fix this. If you put in your config "redirect-gateway def1" it does not replace your default route, it just adds two new routes that are more specific that your default route and uses those instead. Thus when you stop OpenVPN it just tears down those routes and reusing your old default gateway.


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.17.165.16
To prevent spam please submit by clicking the kitten: