WireGuard & NetworkManager

[WireGuard]

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..."

  1. "Connection name"
    Name it whatever you want, OK??. Maybe you can name it just whatever the config is named, like "proton-nl-NL-FREE-###".
  2. Open your WireGuard .conf file in a regular text editor or output the contents in your terminal using cat. While still on the WireGuard tab, set the "interface name" to wg0, and for "Private key", paste your "PrivateKey" string from the .conf file here.

    If you're using a WireGuard config from Proton VPN, DO NOT lose that initial .conf file. 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 .conf file 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.

  3. Then, look at the bottom for "Peers" and click on the "Add" button to the right. Then, do what you've been doing. Like PublicKey gets pasted into "Public key" and yada yada. Just make sure everything here matches your [Peer] block from your .conf file.
  4. Go to the IPv4 Settings tab, change the method to "Manual", click on "Add" and paste the first part of the string from Address under the [Interface] block.

    Inside a WireGuard .conf file, like this one from Proton VPN, Address is shown like this:

    Address = 10.2.0.2/32

    Only the part before the / is the address. The 2 numbers after the / are the Netmask. Which means that you would need to put 32 in the Netmask field. Leave the Gateway blank, as the routing was handled by AllowedIPs.

    Lastly, add the DNS. Paste the address from your .conf's file DNS = 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.