Configuring WireGuard Peers: Ubuntu Server with Two Win 11 Clients
WireGuard is a modern, fast, and secure VPN that utilizes state-of-the-art cryptography. It aims to be simpler and easier to configure than traditional VPNs such as OpenVPN and IPsec. In this article, we will cover how to configure WireGuard on an Ubuntu server with two Win 11 clients.
Prerequisites
- An Ubuntu server with a public IP address
- Two Windows 11 machines
Server Configuration
First, we need to install WireGuard on the Ubuntu server. Run the following commands:
sudo apt update
sudo apt install wireguard
Next, we need to generate the private and public keys for the server:
sudo umask 077
sudo wireguard-generate-keys | tee privatekey > server-private-key
sudo cat server-private-key | grep -o '^[[:alnum:]]*' | head -n 1 > server-public-key
Now, we can create the WireGuard configuration file for the server:
sudo nano /etc/wireguard/wg0.conf
Add the following content to the file:
[Interface]
Address = 10.10.0.1/24
PrivateKey =
ListenPort = 51820
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
Replace
Client Configuration
On each Windows 11 machine, we need to install the WireGuard client and generate the private and public keys:
wg genkey | tee privatekey > client-private-key
wg pubkey < client-private-key | tee publickey > client-public-key
Next, we need to create the WireGuard configuration file for each client:
[Interface]
Address = 10.10.0.2/32
PrivateKey =
DNS = 10.10.0.1
[Peer]
PublicKey =
Endpoint = :51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
Replace
Testing
On each Windows 11 machine, we can now start the WireGuard client and test the connection:
wg-quick up wg0
ping 10.10.0.1
On the Ubuntu server, we can test the connection from the server to the clients:
ping 10.10.0.2
ping 10.10.0.3
References
- WireGuard documentation: https://www.wireguard.com/
- WireGuard Windows client: https://git.zx2c4.com/wireguard-windows/about/
- Ubuntu WireGuard installation: https://www.digitalocean.com/community/tutorials/how-to-set-up-wireguard-on-ubuntu-20-04
This article covered the key concepts of configuring WireGuard on an Ubuntu server with two Win 11 clients. By following the steps outlined in this article, you should be able to securely connect your Windows 11 machines to your Ubuntu server using WireGuard.