Create an encrypted, low-latency private VPN tunnel for secure remote administration and anonymous browsing
By following this guide, you will deploy a high-speed WireGuard VPN server on Ubuntu 24.04. You will configure IPv4 forwarding, set up cryptographic peer keys, and connect client devices with minimal overhead.
Spin up an Ubuntu 24.04 instance with instant activation to test this tutorial:
Deploy IndSoft VPSAn Ubuntu 24.04 VPS with public IPv4. Recommended: IndSoft Low-Latency VPS.
Install WireGuard tools and permit packet forwarding in the Linux kernel.
sudo apt update && sudo apt install wireguard -y
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -pGenerate private and public keys with strict 600 permissions.
umask 077
wg genkey | tee server_private.key | wg pubkey > server_public.key
wg genkey | tee client_private.key | wg pubkey > client_public.keyDefine the VPN subnet, listening port 51820, and iptables NAT forwarding rules.
sudo nano /etc/wireguard/wg0.conf
# [Interface] Address = 10.0.0.1/24, ListenPort = 51820, PrivateKey = ...
# PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo systemctl start wg-quick@wg0
sudo systemctl enable wg-quick@wg0Run this quick verification check to confirm your installation is responding properly:
sudo wg showQuick resolutions for frequent setup pitfalls and configuration issues.
ip route show default.
sudo ufw allow 51820/udp.
DNS = 1.1.1.1, 8.8.8.8.