how to auto start openvpn (client) on ubuntu 12.04 cli?

Solution 1:

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.

Solution 2:

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

    ifconfig
    

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

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

Solution 3:

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