Bug 483120

Summary: [enh] add 'connect automatically' for VPNs
Product: [Fedora] Fedora Reporter: eric <eric>
Component: NetworkManagerAssignee: Lubomir Rintel <lkundrak>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: afonsobordado, bol, bugzilla.redhat.com, cervajs, clancy.kieran+redhat, dcbw, ddosia, iannis, jrh, kagesenshi.87, mcepl, michael.monreal+bugs, psimerda, rkhan, samuel-rhbugs, tom, wtogami
Target Milestone: ---Keywords: FutureFeature, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Attachments:
Description Flags
Script to automatically connect to a VPN
none
Networkmanager autoconnect openvpn log none

Description eric@christensenplace.us 2009-01-29 13:54:59 EST
Description of problem: NetworkManager does not connect to a VPN when the "connect automatically" switch is selected.


Version-Release number of selected component (if applicable): NetworkManager-0.7.0-1.git20090102.fc10.i386


How reproducible: Always


Steps to Reproduce:
1. Select "Connect Automatically" in Editing $VPN
2. Restart computer
3. See a connection automatically establish
  
Actual results: VPN does not automatically connect (or attempt to connect)


Expected results: the VPN automatically connects


Additional info: this is an OpenVPN connection.
Comment 1 Matěj Cepl 2009-06-02 04:33:51 EDT
Still true with soon-to-be Fedora 11 and packages:

vpnc-0.5.3-3.fc11.x86_64
NetworkManager-devel-0.7.1-4.git20090414.fc11.x86_64
NetworkManager-glib-0.7.1-4.git20090414.fc11.x86_64
NetworkManager-0.7.1-4.git20090414.fc11.x86_64
NetworkManager-gnome-0.7.1-4.git20090414.fc11.x86_64
NetworkManager-vpnc-0.7.0.99-1.fc11.x86_64
Comment 2 Bug Zapper 2009-06-09 06:58:08 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Dan Williams 2009-11-06 01:49:16 EST
*** Bug 509773 has been marked as a duplicate of this bug. ***
Comment 4 Dan Williams 2009-11-06 23:37:06 EST
*** Bug 517800 has been marked as a duplicate of this bug. ***
Comment 5 Kieran Clancy 2009-11-16 19:21:40 EST
I do not think that bug 517800 is a dupe of this one. Can you re-open that one?
Comment 6 Dan Williams 2009-11-17 14:56:16 EST
(In reply to comment #5)
> I do not think that bug 517800 is a dupe of this one. Can you re-open that one?  

It's a dupe because the fix for this bug will also include the fix for bug 517800.
Comment 7 bugzilla.redhat.com 2010-05-10 00:05:22 EDT
Is there any update on this?  I still have this problem in version 12.
Comment 8 Michael Monreal 2010-05-10 03:11:22 EDT
(In reply to comment #7)
> I still have this problem in version 12.    

Same for F13 btw
Comment 9 Bug Zapper 2010-11-04 07:31:50 EDT
This message is a reminder that Fedora 12 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 12.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '12'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 12's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 12 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 10 Sebastian Krämer 2010-11-04 07:41:59 EDT
Still the same in F14. Please update version number accordingly.
Comment 11 jrh 2011-07-04 13:21:31 EDT
Same problem in Fedora 15. Does not connect automatically although 'Automatically start connecting next time' is selected.
Works if session is logged out/logged in, but does not work if reboot the OS as described above initially.
Comment 12 Daniil Churikov 2011-08-18 21:12:03 EDT
any hints or workarounds? same issue on FC 15
Comment 13 Kieran Clancy 2011-08-20 01:03:34 EDT
Created attachment 519128 [details]
Script to automatically connect to a VPN

I have the following workaround in place. It should be flexible enough to cover what you want I think:

Place the script at /etc/NetworkManager/dispatcher.d/99-autovpn and make sure it is executable. Make sure NetworkManager is set to NOT automatically start the VPN (since this is what the script does for you instead).

Basically, every time a network connection goes up or down, the script is run, and it matches connections against a triple of data (interface, NM network name, up or down).

In my case, it is set to wait until interface wlan0 connects to "My wireless network", and then starts the VPN named MYVPN. This also works around bug 517800.

1) Change wlan0 to the interface you want to wait for - this could also be eth0.

2) Change "My wireless network" to the name of the network you want to wait for (the name is specified in the NetworkManager configuration). You can just put * (without quotes) if you want to connect regardless of which network you go to.

3) Change "MYVPN" to the name of your VPN connection as specified in NetworkManager.

Obviously, you can make more than one case statement if you want more flexibility.

Each time the script is run, the triple is logged to syslog (/var/log/messages), so you can see what interfaces and network names do or do not trigger the VPN connection.

The script is actually general enough to do quite a few things with it. I have another script like this that detects when I connect to my university wireless network and automatically submits my user/pass to their "web login" page.
Comment 14 Daniil Churikov 2011-08-20 01:30:39 EDT
there is one more problem, when vpn connection closes during network glitch, it will not restore, despite of the option "connect automaticly". as another workaround i put in 99-autovpn such line:
...
case $2 in
  vpn-down)
    nmcli con up uuid $MYVPNUID
  ;;
esac
...

little bit ugly, but it works
ty
Comment 15 cervajs 2011-11-27 15:45:48 EST
i have the same problem. "connect automatically" doesnt work
Comment 16 cervajs 2011-11-27 15:47:07 EST
fedora 16 32-bit, openvpn
Comment 17 Fedora Update System 2012-10-04 10:27:56 EDT
NetworkManager-0.9.7.0-2.git20121004.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/NetworkManager-0.9.7.0-2.git20121004.fc18
Comment 18 Fedora Update System 2012-10-05 14:24:07 EDT
NetworkManager-0.9.7.0-3.git20121004.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/NetworkManager-0.9.7.0-3.git20121004.fc18
Comment 19 Fedora Update System 2012-10-06 01:27:48 EDT
Package NetworkManager-0.9.7.0-3.git20121004.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing NetworkManager-0.9.7.0-3.git20121004.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-15525/NetworkManager-0.9.7.0-3.git20121004.fc18
then log in and leave karma (feedback).
Comment 20 Pavel Šimerda (pavlix) 2012-10-06 15:22:03 EDT
Do we really have VPN autoconnect? I thought we currently had only binding VPNs to connections.
Comment 21 Fedora Update System 2012-10-06 16:10:51 EDT
NetworkManager-0.9.7.0-4.git20121004.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/NetworkManager-0.9.7.0-4.git20121004.fc18
Comment 22 Jirka Klimes 2012-10-10 11:26:40 EDT
Yeah, currently we can just bind VPN to connections, which could serve as a means of auto-connecting.
However, "Connect automatically" checkbox and VPN reconnection when base connection is disrupted still need to be implemented. Back to ASSIGNED.
Comment 23 Izhar Firdaus 2014-12-09 21:59:03 EST
this feature have been missing for quite a while on gnome3 networkmanager .. any news of it coming back ?
Comment 24 Samuel Sieb 2014-12-09 22:08:25 EST
You can use "systemctl enable openvpn@myconnection" to have it start automatically.  However, openvpn has dns issues so I start (and restart) it manually anyway.
Comment 25 Izhar Firdaus 2014-12-09 22:33:26 EST
erm .. aint systemctl command is for connections configured using config file instead of networkmanager? .. 

older networkmanager used to have a way to bind vpn tp connections which will auto-connect vpn when i'm connected to a particular network, but this feature have been missing in newer networkmanager, been waiting for several fedora releases for it to come back, but now on F21, its still missing.
Comment 26 Eric Christensen 2014-12-09 22:56:18 EST
FWIW, I'm no longer seeing this problem now that I'm running KDE.  Must be something GNOME specific.
Comment 27 Izhar Firdaus 2014-12-09 23:14:51 EST
yes, its is gnome specific
Comment 28 Samuel Sieb 2014-12-10 02:37:42 EST
Yes, the systemctl option is a workaround, not a solution.

You can still bind a vpn to a network, but you have to install and use nm-connection-editor.  You will have to run it from the command line as well, since it doesn't show up in the gnome-shell activities view.
Comment 29 Fredrik 2015-01-26 09:45:48 EST
Not sure if my problem fits under this issue, if it doesn't I'll file a separate bug report.

By using the util "nm-connection-editor" the tickbox "Automatically connect to VPN using this connection" exists, and works if I manually connect to the selected Wifi. 

However, my network is marked with "Connect Automatically" in NetworkManager and upon a reboot Network manager fails to connect to my wifi if the setting "Automatically connect to VPN using this connection", and I must connect manually to the WiFi network that should auto-connect.

Not a huge issue, but still annoying. 

Versions:
NetworkManager-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-openvpn-gnome-0.9.9.0-3.git20140128.fc21.x86_64
NetworkManager-pptp-0.9.8.2-6.fc21.x86_64
NetworkManager-adsl-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-wwan-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-bluetooth-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-glib-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-pptp-gnome-0.9.8.2-6.fc21.x86_64
NetworkManager-openconnect-0.9.8.6-2.fc21.x86_64
NetworkManager-vpnc-0.9.9.0-6.git20140428.fc21.x86_64
NetworkManager-vpnc-gnome-0.9.9.0-6.git20140428.fc21.x86_64
NetworkManager-wifi-0.9.10.1-1.4.20150115git.fc21.x86_64
NetworkManager-openvpn-0.9.9.0-3.git20140128.fc21.x86_64
NetworkManager-l2tp-0.9.8.7-3.fc21.x86_64
NetworkManager-config-connectivity-fedora-0.9.10.1-1.4.20150115git.fc21.x86_64
nm-connection-editor-0.9.9.0-15.git20140424.fc21.x86_64
Comment 30 Eric Christensen 2015-01-26 10:20:05 EST
Yeah, I suspect this is a slightly different problem but I'm also seeing that on F20.
Comment 31 Fredrik 2015-01-26 23:03:49 EST
Update: found my particular issue with the wifi not connecting upon boot, by unticking the setting "Make available to other users" both on WiFi and on the VPN configuration, the issue disappears and both WiFi and VPN connects upon login.
Comment 32 Fedora Admin XMLRPC Client 2015-08-18 10:56:30 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 33 Fredrik 2015-11-12 15:24 EST
Created attachment 1093445 [details]
Networkmanager autoconnect openvpn log
Comment 34 Fredrik 2015-11-12 15:26:21 EST
Hi, 
I have an update regarding this issue in Fedora 23 (the same behaviour was seen in fedora 22).

The issue is in my case that Networkmanager tries to connect a number of times when I login after a reboot, and after maybe 3-5 times, it bails out due to unsuccessful connection attempts.
When I manually connect to my wifi, openvpn autoconnects just fine.

The same issues is experienced when returning from sleep, and a cold boot.

For more information on the issue, see the attached log above: Networkmanager autoconnect openvpn log (journalctl -b --unit=NetworkManager)

The following settings is configured for my WiFi in nm-connection-manager:
"Automatically connect to this network when it is available"
"All users may connect to this network"
"Automatically connect to VPN when using this connection": VPN

NetworkManager and openvpn packages installed:

NetworkManager-wwan-1.0.6-8.fc23.x86_64
NetworkManager-1.0.6-8.fc23.x86_64
NetworkManager-openconnect-1.0.2-2.fc23.x86_64
NetworkManager-team-1.0.6-8.fc23.x86_64
NetworkManager-bluetooth-1.0.6-8.fc23.x86_64
NetworkManager-vpnc-gnome-1.0.6-3.fc23.x86_64
NetworkManager-libnm-1.0.6-8.fc23.x86_64
NetworkManager-openvpn-1.0.6-3.fc23.x86_64
NetworkManager-wifi-1.0.6-8.fc23.x86_64
NetworkManager-vpnc-1.0.6-3.fc23.x86_64
NetworkManager-openvpn-gnome-1.0.6-3.fc23.x86_64
NetworkManager-l2tp-0.9.8.7-4.fc23.x86_64
NetworkManager-pptp-1.1.0-2.20150428git695d4f2.fc23.x86_64
NetworkManager-config-connectivity-fedora-1.0.6-8.fc23.x86_64
NetworkManager-glib-1.0.6-8.fc23.x86_64
NetworkManager-adsl-1.0.6-8.fc23.x86_64
NetworkManager-pptp-gnome-1.1.0-2.20150428git695d4f2.fc23.x86_64
[root@hell tmp]# rpm -qa | grep openvpn
NetworkManager-openvpn-1.0.6-3.fc23.x86_64
NetworkManager-openvpn-gnome-1.0.6-3.fc23.x86_64


openvpn-2.3.8-1.fc23.x86_64
Comment 35 Jirka Klimes 2015-11-16 03:40:46 EST
(In reply to Fredrik from comment #34)
> Hi, 
> I have an update regarding this issue in Fedora 23 (the same behaviour was
> seen in fedora 22).
> 
> The issue is in my case that Networkmanager tries to connect a number of
> times when I login after a reboot, and after maybe 3-5 times, it bails out
> due to unsuccessful connection attempts.
> When I manually connect to my wifi, openvpn autoconnects just fine.
> 

The issue is not specific to VPN/Wifi or a specific type of connection. There are missing secrets. The connections profiles that should be started on boot cannot depend on user agents providing secrets, because such secret agents are not available yet. So if, for example, you have a Wi-Fi connection and you store a password in a keyring, the connection can't be activated until you log in and an agent may provide NetworkManager with the password from the keyring.

Nov 12 20:37:42 hell NetworkManager[936]: <error> [1447357062.570348] [vpn-manager/nm-vpn-connection.c:1980] get_secrets_cb(): Failed to request VPN secrets #3: (4) No agents were available for this request.
Comment 36 Fredrik 2015-11-17 15:23:51 EST
(In reply to Jirka Klimes from comment #35)

> 
> The issue is not specific to VPN/Wifi or a specific type of connection.
> There are missing secrets. The connections profiles that should be started
> on boot cannot depend on user agents providing secrets, because such secret
> agents are not available yet. So if, for example, you have a Wi-Fi
> connection and you store a password in a keyring, the connection can't be
> activated until you log in and an agent may provide NetworkManager with the
> password from the keyring.
> 
> Nov 12 20:37:42 hell NetworkManager[936]: <error> [1447357062.570348]
> [vpn-manager/nm-vpn-connection.c:1980] get_secrets_cb(): Failed to request
> VPN secrets #3: (4) No agents were available for this request.

Well in that case shouldn't the keyring and therefore the secrets be available after a successful login?
The issues are occurring post-login, and the nm-applet icon is flickering during the connection attempts until it stalls.

After the stalling and a manual connection to the wifi is attempted, the connection is established successfully - both to the wifi and the VPN.

So the issue seems to be a communication issue between the keyring and NetworkManager then?