25

I am using Ubuntu 12.04.2 LTS, 64-bit, OpenVPN client 2.3.1

How do I prevent OpenVPN from autostarting at boot-up or reboot?

Eric Carvalho
  • 54,385
n00b
  • 1,897
  • According to OpenVPN's website (http://openvpn.net/index.php/download/community-downloads.html), it is recommended to use the current stable release. Specifically the download link for 2.3.1 is http://repos.openvpn.net/repos/apt/precise-stable/openvpn_2.3.1-debian0_amd64.deb What I did was to right-click the URL and was given the option to save it locally or opened with "Ubuntu Software Center". I chose the latter and installed it with the help of "Ubuntu Software Center". – n00b Jun 02 '13 at 09:06

2 Answers2

41

You have two options:

  • Run:

    sudo update-rc.d openvpn disable
    

    Then you'll have to run sudo service openvpn start to manually start the VPN.

  • Or edit the file /etc/default/openvpn

    sudo gedit /etc/default/openvpn
    

    And uncomment the line:

    #AUTOSTART="none"
    

    So it looks like:

    AUTOSTART="none"
    

    Then you'll have to run sudo service openvpn start <vpn-name> to manually start the VPN. <vpn-name> is the config file name without .conf.

Eric Carvalho
  • 54,385
  • Thanks Eric for your help. Can I put more than 10 config files in /etc/openvpn/ ? – n00b Jun 02 '13 at 12:43
  • 1
    As many as you want. I don't know about its limits, but I think you could have a reasonably high number of config files. – Eric Carvalho Jun 02 '13 at 13:15
  • Eric: If I choose Option 1, ie. to run sudo update-rc.d openvpn disable, if I wish to re-enable autostart, do I use the command: sudo update-rc.d openvpn enable ? – n00b Jun 02 '13 at 14:31
  • 1
    Yes, sudo update-rc.d openvpn enable. – Eric Carvalho Jun 02 '13 at 14:39
  • Thanks Eric for your help. Would you mind looking at the question indicated by the following link: http://askubuntu.com/questions/303203/could-someone-tell-me-whether-my-os-is-communicating-with-the-internet – n00b Jun 02 '13 at 15:10
  • Hello @EricCarvalho: thanks for the answer. Is it some sort of standard ? Can I add the AUTOSTART="none" to another service file (I'd like to prevent supervisor from auto-starting) ? Or is it just for OpenVPN ? – Anto Oct 08 '13 at 12:52
  • +1 for sudo service openvpn start <vpn-name> – pylover Nov 15 '14 at 16:03
  • 2
    update-rc.d is init.d related, the new way to process is using systemd. systemctl is-enabled openvpn@vpn-name to learn if it's enabled, systemctl disable openvpn@vpn-name to disable on startup. – Nek Jun 16 '20 at 08:14
  • 1
    None of this works for me. I always have an /usr/sbin/openvpn running after bootup that I have to manually kill, but it comes back on reboot – Displayname71 Nov 09 '21 at 21:15
  • Same problem as @Displayname71 - openvpn running again right after reboot. – oemb1905 Jun 14 '23 at 05:26
2

Nothing on this page helped me, but it was pinned by Google.

The command that fixed my problem:

sudo systemctl disable openvpn@client.service

I am running Ubuntu 20.10 with Openvpn v. 2.4.9

RE: https://www.ivpn.net/knowledgebase/linux/linux-autostart-openvpn-in-systemd-ubuntu/

  • Oddly, this also does not stop the server from starting after reboot. I ended up having to do sudo systemctl disable openvpn to get it to work. – oemb1905 Jun 14 '23 at 05:28