Saturday, November 10, 2007

Start/Stop OpenVPN with ifupdown

Starting and stopping OpenVPN in Debian or Ubuntu Gutsy when an interface comes up and down is as easy as adding a single line to your /etc/network/interfaces configuration file.  After a while of searching for a clean way to do this, I came upon this mailing list post.  Sure enough, /usr/share/doc/openvpn/README.Debian.gz had all the gory details (nothing in the man pages for interfaces or openvpn).

Quick /etc/network/interfaces example:

iface eth0 inet dhcp

openvpn my-vpn

The my-vpn is used to select the appropriate OpenVPN configuration file (.conf extension) in the /etc/openvpn directory.  After adding the above configuration, ifup eth0 and ifdown eth0 will start/stop the OpenVPN connection.