How to get a WireGuard configuration working via NetworkManager
Well... First you need to have one. If you aren't self-hosting a VPN or something, or don't know from where to get one, then Proton VPN offers free WireGuard configurations which are good for tinkering with & you can see how to get one here.
Also, here it's assumed you have NetworkManager set up. Afterwards all you need is
nm-connection-editor if you don't have it already.
Import your configuration
Open nm-connection-editor, like from your terminal or launcher or something.
Click the + button at the bottom left. Scroll down to the Virtual section and select WireGuard, then click "Create..."
- "Connection name"
Name it whatever you want, OK??. Maybe you can name it just whatever the config is named, like "proton-nl-NL-FREE-###". - Open your WireGuard
.conffile in a regular text editor or output the contents in your terminal usingcat. While still on the WireGuard tab, set the "interface name" towg0, and for "Private key", paste your "PrivateKey" string from the.conffile here.If you're using a WireGuard config from Proton VPN, DO NOT lose that initial
.conffile. Because Proton VPN adheres to a strict "zero-knowledge" security model or whatever, their servers do not store your private keys once they are generated. The private key is injected into the.conffile and shown to you exactly once right after being created. If you go back to the dashboard and click "Download" on that same previously created configuration, the server would not supply the key because it no longer has it, resulting in it just being asterisks. You'd have to generate a new configuration if you lose your private key. - Then, look at the bottom for "Peers" and click on the "Add"
button to the right. Then, do what you've been doing. Like
PublicKeygets pasted into "Public key" and yada yada. Just make sure everything here matches your[Peer]block from your.conffile. - Go to the IPv4 Settings tab, change the method to "Manual",
click on "Add" and paste the first part of the string from
Addressunder the[Interface]block.Inside a WireGuard
.conffile, like this one from Proton VPN,Addressis shown like this:Address = 10.2.0.2/32
Only the part before the
/is the address. The 2 numbers after the/are theNetmask. Which means that you would need to put 32 in theNetmaskfield. Leave the Gateway blank, as the routing was handled byAllowedIPs.Lastly, add the DNS. Paste the address from your
.conf's fileDNS =line into the "DNS servers" text field. Then, save.
Done. It should show up now & work. I personally use nm-applet for the super neat
tray icon from which I like to toggle my VPNs on & off.
But you can use other things too! nmtui is another super neat interface for your
terminal to configure your connections. There's also nmcli commands.