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!
sudo nmcli connection import type wireguard file /etc/wireguard/wg0.conf
(sudo needed so it can read the contents of the wg0 config file)
Then to verify it’s there you can run:
ip addr ; nmcli con show
Network Manager CLI might be annoying to deal with however, in which case you can import the config file through searching for “Advanced Network Configuration”, or running nm-connection-editor to launch it from the terminal
Once it’s open click on the plus sign on the bottom left, on the “Choose a Connection Type” click on the box with the arrow, scroll down to Virtual, and click on WireGuard to create from scratch.
No clue how importing a .conf file works through this GUI but what I personally do is import it through nmcli and then manage it through the nm-connection-editor GUI
If you don’t have nm-connection-editor installed you can install it with:
sudo apt install network-manager-gnome
nm-connection-editor should be launchable and searchable through the term “Advanced Network Configuration”, you may confirm this as such:
Once you import a conf file through network manager’s nmcli it’ll automatically show up under this GNOME extension, allowing you to easily turn WireGuard connections on and off from the systray
I see. When I setting up wiregurad on my private VPS, bash-script configured two connections (two .conf files). One for the smartphone and one for the laptop. On the laptop I use KDE. NetworkManager-KDE has support for wireguard, but I was never able to set up the connection with KDE itself. The connection was created, but it didn’t work. So I used the CLI utility “nmcli” (here is a good article on this case - https://tinyurl.com/2lrfzoyo).
sudo nmcli connection import type wireguard file .conf
After that the connection with the right type appeared in the list of connections, and it worked without any problems. I understand that you probably have GNOME and maybe my method won’t work for you. Best luck. Translated with www.DeepL.com/Translator (free version)