How to import WireGuard profile using nmcli on Linux

Importing WireGuard profile

Suppose I have a wireguard connection profile file:

INI
[Interface]
PrivateKey = {private-key-here}
Address = 10.8.1.2/24
DNS = 10.8.1.1
[Peer]
PublicKey = {Pub-key-here}
PresharedKey = {Pre-shared-key-here}
AllowedIPs = 0.0.0.0/0
Endpoint = $Linux_SERVER_IP_HERE:$Port
Click to expand and view more


It can be import into network manager with command:

SH
$ nmcli connection import type wireguard file "/path/to/wg0.conf"
Click to expand and view more

Then I can connect/disconnect the VPN using tray applet.

Autoconnect can be modified with command

SH
$ nmcli connection modify home-vpn connection.autoconnect no
Click to expand and view more

Copyright Notice

Author: Vorasilp K.

Link: https://vorasilp.xom/posts/how-to-import-wireguard-profile-using-nmcli-on-linux/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut