Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

Thanks

share|improve this question
add comment

5 Answers

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.

share|improve this answer
    
I tried that. All values were commented out and the documentation stated that the default was all. –  waspinator Dec 17 '12 at 15:23
add comment

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

share|improve this answer
add comment

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]

respawn

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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