Announcement

Collapse
No announcement yet.

openvpn, automaticaaly opening connection on startup

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    openvpn, automaticaaly opening connection on startup

    I've been through all of the docs I can find (net and local).

    I want to have openvpn automatically connect to the vpn server on startup.

    I have tried the "AUTOSTART" command in the /etc/default/openvpn file - no good

    I have tried copying the desired server configuration file to the etc/openvpn directory - no good

    Both methods were described in the docs I could find and were supposed to automatically cause openvpn to connect to the desired vpn. Neither worked.

    I can click on the network icon in the menu bar, then click on the desired vpn listed and the connection will be made in a few seconds.

    I want it done automatically, before any programs access the inetrnet.

    Any suggestions on how to get openvpn to connect automatically on startup?

    #2
    when you click the network icon in the system tray >manage conections>VPN>select your VPN and click edit ..........do you have "connect automaticly" and is "system conection" checked ?

    VINNY
    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    Comment


      #3
      Originally posted by vinnywright View Post
      when you click the network icon in the system tray >manage conections>VPN>select your VPN and click edit ..........do you have "connect automaticly" and is "system conection" checked ?

      VINNY
      yes

      Comment


        #4
        Originally posted by geezer View Post
        yes
        ? thats all I had ,,,,, never used a VPN so have no way of tinkering with ya to see.

        VINNY
        i7 4core HT 8MB L3 2.9GHz
        16GB RAM
        Nvidia GTX 860M 4GB RAM 1152 cuda cores

        Comment


          #5
          First, display a list of all connections that Network Manager knows about:
          Code:
          nmcli con list
          Note the name of your VPN connection .

          Next, test starting the VPN via the command:
          Code:
          nmcli con up id [i]CONNECTION-NAME[/i]
          where CONNECTION-NAME is the name you noted earlier. If it works, the Network Manager icon in the system tray should change to a yellow lock.

          Now verify that you can stop the VPN:
          Code:
          nmcli con down id [i]CONNECTION-NAME[/i]
          The yellow lock icon should disappear.

          Now, the tricky part is timing this to automatically run only after a base connection is made -- either LAN or wireless. The Arch wiki has a script that you might take a look at; it's reported to work in *buntu 13.04.

          Comment


            #6
            Originally posted by SteveRiley View Post
            First, display a list of all connections that Network Manager knows about:
            Code:
            nmcli con list
            Note the name of your VPN connection .

            Next, test starting the VPN via the command:
            Code:
            nmcli con up id [i]CONNECTION-NAME[/i]
            where CONNECTION-NAME is the name you noted earlier. If it works, the Network Manager icon in the system tray should change to a yellow lock.

            Now verify that you can stop the VPN:
            Code:
            nmcli con down id [i]CONNECTION-NAME[/i]
            The yellow lock icon should disappear.

            Now, the tricky part is timing this to automatically run only after a base connection is made -- either LAN or wireless. The Arch wiki has a script that you might take a look at; it's reported to work in *buntu 13.04.
            Thank you.

            I executed the first command you specified. It only listed the same possible VPN connections I have created via the netwotk manager. So that confirms them I guess.

            As for the lock on the network icon, I get that by simply clicking on the netowrk icon and then clicking on the vpn connection I want at the moment. And yes the lock does appear when the connection has been made. And yes I can stop the vpn connection again by clicking on the network icon and then on the red 'x' to the right of the current vpn connection.

            I'll check out the link you gave. Thanks for that.

            Comment


              #7
              Okay problem solved. Maybe not the most elegant solution, but it works. The link above that SteveRiley gave pointed me in the right direction.

              First create the following script file:

              #! /bin/sh
              #
              # script to open Desired VPN on startup
              #

              /usr/bin/nmcli con up id Your_Desired_VPN_Name
              Save the file in an accessable directory (/usr/local/bin is a good place). Change the permissions to make it executable.

              Open the 'System Settings' dialog and click on 'Startup and Shutdown' then highlight the 'Script File' line and click on 'Add Script'. Either type in the full path and file name of the file you just created or use the browse button to find it. Click 'OK'. Now if you want the VPN connected prior to any browser or other program that accesses the internet, change the 'Run' setting to 'Pre-KDE Start-up'. Close the 'System Settings dialog.

              The next time you boot, the VPN connection will be made automatically to your desired VPN.

              Comment


                #8
                I'd recommend something closer to the script on the Arch wiki. Yours will only run once after boot, and if the underlying real interface isn't yet configured, it will fail.

                Comment


                  #9
                  SteveRiley:

                  True - If I understand your comment, if the wired/wireless interface isn't working then it will fail. Is this what you meant?

                  Also, do you mean that the arch wiki script will be retried until success?? Does the network manager /etc/NetworkManager/dispatcher.d/vpn.up file get run automatically by netwrok manager when it boots? Is this a special directory that network manager looks for for scripts to run when it boots?

                  Comment


                    #10
                    Okay - I've tried it again and read the NetworkManager man page.

                    I've gotten to work.

                    /etc/networkmanager/dispatcher.d file has the added advantage/disadvantage. I've found that if disconnect the vpn, network manager immediately executes the script again and connects the disconnected vpn. This can be an advantage. The advantage is obvious for wireless networks.

                    However, there is also a disadvantage. If I'm traveling and want to switch the vpn server (or if even if I'm not traveling and want to switch the vpn server, say to another country), then I have to edit the script file or somehow deactivate it. Then I can manually switch servers. bothersome.

                    On the whole, for me, I would say the advantages outweight the disadvantage.

                    Comment


                      #11
                      Well, this is just plain weird.

                      Using the script file in /etc/NetworkManager/dispatcher.d works just great on my desktop computer. The vpn is already connected when KDE boots and it automatically reconnects when I manually disconnect.

                      But on my laptop, the vpn does not get connected on boot. I can manually connect to the vpn and then network manager automatically reconnects when I manually disconnect. So the script file in /etc/NetworkManager/dispatcher.d is working, but network manager doesn't use it on boot for some strange reason.

                      Both computers are connected to the same router via ethernet and the vpn setup on both machines is identical. I created the vpn accounts on the desktop machine, exported them and then imported them on the laptop. So the setups are identical. Both are running Kubuntu 13.04.

                      Works on booting on the desktop, but not on booting the laptop. Weird.

                      Comment


                        #12
                        Okay - I have gone back to the KDE start-up script approach.

                        I have found the /etc/NetworkManager/dispatcher.d script file approach to be too unreliable. True, it might not start the vpn on startup because the network isn't up yet, but that I can spot easily by checking the network icon.

                        Also, I have found that there are more times than I thought that I want to change the VPN server I want to use. The /etc/NetworkManager/dispatcher.d script file approach does not allow me to change the vpn server.

                        Comment

                        Working...
                        X