WireGuard is a small, fast VPN. Running it on your own VPS takes about ten minutes and gives you a fixed address and full control. This guide uses Debian or Ubuntu with root access. Commands differ slightly on other systems, so check the official WireGuard documentation if something does not match.
Log in as root and run:
apt update && apt install -y wireguard
umask 077
wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub
wg genkey | tee /root/client1.key | wg pubkey > /root/client1.pubThe server and each client have a private key (secret) and a public key (shared with the other side).
Find the name of your network interface with ip route get 1.1.1.1 (often eth0 or ens3). Then create /etc/wireguard/wg0.conf:
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = (contents of server.key)
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 = (contents of client1.pub)
AllowedIPs = 10.8.0.2/32Replace eth0 with your interface name. Turn on forwarding and start the tunnel:
echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/99-wg.conf && sysctl --system
systemctl enable --now wg-quick@wg0Allow the WireGuard port and SSH in your firewall, and nothing you do not need. With ufw:
ufw allow 22/tcp
ufw allow 51820/udp
ufw enableOn the client, create a config like this and import it into the WireGuard app:
[Interface]
PrivateKey = (contents of client1.key)
Address = 10.8.0.2/24
DNS = 1.1.1.1
[Peer]
PublicKey = (contents of server.pub)
Endpoint = YOUR.SERVER.IP:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25Connect, then check your public address on any "what is my IP" page. It should show the server.
Related: VPN server hosting · Choosing a VPS for Xray, V2Ray or AmneziaWG · Test IPs · No-KYC VPS · FAQ
See the Fast VPS plans (from $7.99 a month), the NVMe VPS plans or the dedicated servers. Sign up with an email address and a nickname, pay with Monero, Bitcoin, Litecoin, USDT, USDC, SOL or TRX, or by card. New VPS orders carry a 24-hour guarantee. Before you pay you can ping our test IPs and read the live status page.