I have an *.ovpn file that works if I type in

sudo openvpn client.ovpn

Now I would like to start up openvpn when I boot the computer. It's a headless version of ubuntu - if that matters - 12.04 64bit.

I copied filename.ovpn to /etc/openvpn but it's not starting, even if I run

service openvpn start

How can I do this?

7 Answers 7


On Ubuntu any VPN configuration you place in a file named /etc/openvpn/$NAME.conf will be automatically started.

So, all you have to do is copy your client.ovpn to /etc/openvpn/client.conf. I suggest you also use absolute paths in your client.conf for any keys, scripts and so on.

Of course, you might want to double check the /etc/default/openvpn file. By default it will autostart all VPNs, but the AUTOSTART value could have been changed to none, or to be a list of the specific configurations you want automatically started.

  • 1
    I tried that. All values were commented out and the documentation stated that the default was all.
    – waspinator
    Dec 17, 2012 at 15:23

For Debian OS

  1. Place your configuration file into /etc/openvpn, for example /etc/openvpn/client.conf.

  2. Prefix/comment out lines starting with "down" and "up" (#down and #up) - or delete them (these are calling external script) from client.conf

  3. Reload openvpn configuration

    /etc/init.d/openvpn reload /etc/openvpn/client.conf
  4. Check with


    Do you see tun0 interface? Does it have IP assigned? Great.

  5. Remember the IP, reboot and try to connect.


The client config must have the extension .conf and not .ovpn. Changing client.ovpn to client.conf in /etc/openvpn should work


It would be nice to have a un hacker way of doing it, but this will have to do for now.

1) Create file myopenvpn in /etc/init/

nano /etc/init/myopenvpn

2) Insert into myopenvpn and save:

# OpenVPN autostart on boot upstart job

start on runlevel [2345]
stop on runlevel [!2345]


exec /usr/sbin/openvpn --status /var/run/openvpn.client.status 10 --cd /etc/openvpn --config /etc/openvpn/client.conf --syslog openvpn

SOURCE: http://www.hackerway.ch/2012/12/11/how-to-auto-start-openvpn-client-in-debian-6-and-ubuntu-12-04/#comment-79


You'll have to put this information inside the initialization scripting for openvpn in /etc/init.d. AND aqd appropriate symlinks to the appropriate run level based /etc/rc.d files so that it starts and stops.


I did it on a CentOS box with the following command inserted into /etc/rc.local:

openvpn --config /path/to/file.ovpn &

The commands in that file are executed after every multi-user runlevel finishes booting and unlike adding it to a startup script it will not slow down your boot if the VPN takes long to setup, but some people would call this a hack.

  • This isn't the Right Way to handle this, especially since Debian already has an initscript which does this.
    – mgorven
    May 24, 2013 at 20:12
  • That's why I added that some people consider this a hack. This is not elegant but does the trick. May 24, 2013 at 20:14

Note that for 16.04 onward you'll need this:

systemctl start openvpn@server.service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.