Add Linux Client to a Wireguard VPN
·1 min
Table of Contents
Login ssh into server:
Install wireguard:
sudo apt install wireguard
Move into the wireguard
directory:
sudo su
cd /etc/wireguard
Copy the Wireguard config file into a wg0.conf
file. To do so, run the following command with your proper wireguard conf file:
echo "
[Interface]
PrivateKey = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Address = 10.0.0.7/24
DNS = 1.1.1.1,1.0.0.1
[Peer]
PublicKey = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PresharedKey = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
Endpoint = wg.server.com:51820" > /etc/wireguard/wg0.conf
Now, enable the wireguard interface wg0
, so the server can connect to the VPN.
sudo wg-quick up wg0
In Ubuntu 20.04 I found a problem with resolvconf
Ref
Creating this simlink solves the error:
ln -s /usr/bin/resolvectl /usr/local/bin/resolvconf
Starting a VPN Client Automatically #
If youβve added a wg-quick config, e.g. /etc/wireguard/wg0.conf, you can enable autostarting it on system boot using systemd:
sudo systemctl enable --now wg-quick@wg0
If you have started Wireguard with this config manually before, you need to shut it down first or systemd will not be able to start it !