WireGuard is a modern, fast VPN with a small config. On a VPS it lets you reach internal services or egress with the server IP.
Steps
Install WireGuard and tools:
sudo apt updatesudo apt install -y wireguard wireguard-toolsGenerate server keys (keep the private key secret):
umask 077wg genkey | tee /etc/wireguard/server_private.key | wg pubkey > /etc/wireguard/server_public.keysudo chmod 600 /etc/wireguard/server_private.keyCreate /etc/wireguard/wg0.conf (adjust IP and key):
sudo tee /etc/wireguard/wg0.conf >/dev/null <<'EOF'[Interface]Address = 10.8.0.1/24ListenPort = 51820PrivateKey = SERVER_PRIVATE_KEY# [Peer]# PublicKey = CLIENT_PUBLIC_KEY# AllowedIPs = 10.8.0.2/32EOFOpen UDP, enable IP forwarding and start the interface:
sudo ufw allow 51820/udpecho 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-wireguard.confsudo sysctl --systemsudo systemctl enable --now wg-quick@wg0sudo wg show
Tips
- Add each client as a
[Peer]with its public key and a 10.8.0.x/32 address. - For NAT to the internet, add
PostUp/PostDowniptables rules on the public NIC.
ext step
Fixed IP and solid uplink for your VPN: Deploy your Cloud VPS.