← Blog

How to Set Up WireGuard on Ubuntu 24.04

Ubuntu 24.04 LTS is a straightforward platform for a personal WireGuard server. You need a VPS or spare Linux machine, sudo access, and one client key pair for each device.

Install the Ubuntu package

sudo apt update
sudo apt install wireguard
wg --version
Keep a second SSH session open while changing firewall settings.

Create keys and the tunnel

Use 10.8.0.0/24 as the tunnel network. Give the server 10.8.0.1 and the first client 10.8.0.2. Generate keys with umask 077 so private keys stay private.

Configure forwarding and NAT

Enable net.ipv4.ip_forward = 1, allow UDP 51820, and add MASQUERADE on the actual public interface. Find it with ip route get 1.1.1.1.

Start and test

sudo systemctl enable --now wg-quick@wg0
sudo wg show
Connect a client, confirm the handshake, check the public IP, and run a DNS leak test.

Quick checklist

  • Ubuntu 24.04 is updated.
  • Private keys use restrictive permissions.
  • Forwarding, NAT, and UDP access are enabled.
  • The client handshake and internet route work.

This guide focuses on practical self-hosting. See the complete WireGuard server guide for the full setup. Tired of maintaining the server yourself? ZeroBlock handles the VPN infrastructure so you can connect without managing a VPS.