Step 1: Install WireGuard
sudo apt update && sudo apt install wireguard -yStep 2: Generate Server Keys
cd /etc/wireguard
umask 077
wg genkey | tee server_private_key | wg pubkey > server_public_keyStep 3: Create Server Config
sudo nano /etc/wireguard/wg0.confAdd:
[Interface]
PrivateKey =
Address = 10.0.0.1/24
ListenPort = 51820
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
PublicKey =
AllowedIPs = 10.0.0.2/32Step 4: Enable IP Forwarding
sudo sysctl -w net.ipv4.ip_forward=1
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.confStep 5: Start WireGuard
sudo systemctl start wg-quick@wg0
sudo systemctl enable wg-quick@wg0