I'm having trouble adding a WireGuard VPN connection to the Network Manager on Ubuntu. I've followed several online tutorials and tried different methods, but nothing seems to work.
I've installed WireGuard using the sudo apt install wireguard command and created the configuration file /etc/wireguard/wg0.conf . The VPN connection works fine when I start it using the sudo wg-quick up wg0 command, but I can't seem to add it to the Network Manager.
When I go to "Add VPN Connection" in the Network Manager, I only see options for OpenVPN and PPTP. There's also an option to "Import from file", but when I select my wg0.conf file, it says that the file format is not supported.
I've tried restarting the Network Manager with sudo service network-manager restart , but that doesn't seem to help. I'm running Ubuntu 22.04.1 LTS.
Any help or suggestions would be greatly appreciated. Thanks in advance!
nmcli connection import [...]line above it will be set to auto reconnect whenever your network is started: e.g. if you import the Wireguard VPN but then disconnect from it, doing a laptop suspend/resume will cause it to automatically connect to the VPN again without an explicit user action. If you don't want this behaviour run,nmcli connection modify MyWG connection.autoconnect noafter the import has been successful. – Anon Jun 01 '25 at 06:27connection.autoconnect = no, and I'm certain I didn't touch this option. UPD: or alternatively, perhaps the behavior might have changed in newer NetworkManager versions…? My current NM is 1.52.0, it was older when I imported the connection, I think that was 1.5-2 years ago. – Hi-Angel Jun 01 '25 at 06:45connection.type = vpn, but WG connection is mistakenly markedwireguard. I'm not sure however that changing it tovpnwouldn't break something else, so at this point I stopped digging. I guess I'll re-check once export is fixed (or I get a new config). – Hi-Angel Jun 01 '25 at 09:20nmcli connection import [...]thenconnection.autoconnectis set to yes. On Ubuntu 24.04/25.04 when I imported the WireGuard config using the UI (via Settings | Network, VPN +, then choosing "Import from file...") then usingnmcli connection show [...]showed thatconnection.autoconnectwas set to no. – Anon Jun 01 '25 at 09:46