Score:1

How can I set up network manager to auto-connect at boot-time to a Wi-Fi and a WireGuard VPN?

il flag

How can I set up network manager to auto-connect at boot-time to a Wi-Fi and a WireGuard VPN?

I configured Network Manager with 2 connections: a Wi-Fi and a WireGuard VPN. They both work when I start them up manually. I've set-up both connections to auto-start upon boot. After booting, both connections show as active and connected, but I cannot access the network/internet. If I restart manually the WireGuard VPN, everything works and I am able to access the network again.

This is very annoying! Any ideas what could be wrong and how can I set this up correctly?

Network connections - Wireguard VPN settings Network connections - Wi-Fi H369.... settings

FYI I am running Kubuntu 22.10. Also FYI, the Network Manager connection configuration files

**SS-NL-WG**  
[connection]  
id=SS-NL-WG  
uuid=9xxxxxxxxxx7  
type=wireguard  
autoconnect-priority=10  
interface-name=SS-NL-WG  

[wireguard]  
private-key=xxxxxxxxxxxxxx=  

[wireguard-peer.xxxxxxx=]  
endpoint=xxxxxxxx.com:51820  
allowed-ips=0.0.0.0/0;  

[ipv4]  
address1=10.14.0.0/16  
dns=xxxxxxxxxx;  
method=manual  

[ipv6]  
addr-gen-mode=stable-privacy  
method=disabled  

##H369A3D4517## (wi-fi)  
[connection]  
id=H369A3D4517  
uuid=fxxxxxxxxxxxxxxxxxx9  
type=wifi  
autoconnect-priority=10  

[wifi]  
mode=infrastructure  
ssid=H369A3D4517  

[wifi-security]  
key-mgmt=wpa-psk  
psk=xxxxxxxxxxxx  

[ipv4]  
method=auto  

[ipv6]  
addr-gen-mode=stable-privacy  
method=auto  
Score:0
ru flag

I am trying to achieve the same as you but have not managed yet. My guess why your approach does not work is that probably wireguard comes up first but cannot resolve the IP address of the wireguard endpoint (as the wifi connection is not yet up and so DNS requests wont get through). This means that all your traffic will be routed nowwhere.

Someone posted here that this worked for them:

$ nmcli connection modify myvpn-wg connection.autoconnect yes
$ nmcli connection modify WLANEG connection.autoconnect-priority 1

Unfortunately, this did not work for me though.

vbee avatar
il flag
This is exactly why it doesn't work. Unfortunately this is related to the way network manager works (or better, doesn't) with non-OpenVPN connections. It simply doesn't support that. I found out this is know for over 10 years but it hasn't been fixed. I checked the upstream/source developers and it's a known issue. What I did eventually is using OpenVPN instead of wireguard VPN protocol and it just works. I am not happy bit I don't want to configure the wireguard package to create a custom peer thay doesn't integrate into the network-manager gui.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.