Enzonic VPS
Cyber Monday: 40% off your first 2 months on VPS plans.Ends in 1d 3hSee deal prices
Guides · 12 min read

Run your own WireGuard VPN on an Enzonic VPS

Set up a WireGuard VPN server on one of your forwarded UDP ports, with IPv4 and IPv6 for your devices.

WireGuard needs one UDP port. On the shared IPv4 use one of your forwarded ports (they keep the same number inside the VPS); over IPv6 any port works. A personal VPN for your own traffic is allowed by the acceptable use policy; open proxies are not.

  1. 1Install WireGuard

    WireGuard is in the Linux kernel on every image; this installs the tools.

    sudo apt install -y wireguard qrencode
  2. 2Create the server keys

    Keep the private key private: it never leaves the VPS.

    umask 077
    wg genkey | sudo tee /etc/wireguard/server.key | wg pubkey | sudo tee /etc/wireguard/server.pub
  3. 3Write the server config

    Replace 30021 with one of your forwarded ports, and eth0 with your interface (ip route shows it).

    sudo tee /etc/wireguard/wg0.conf >/dev/null <<EOF
    [Interface]
    Address = 10.66.0.1/24
    ListenPort = 30021
    PrivateKey = $(sudo cat /etc/wireguard/server.key)
    PostUp = iptables -t nat -A POSTROUTING -s 10.66.0.0/24 -o eth0 -j MASQUERADE
    PostDown = iptables -t nat -D POSTROUTING -s 10.66.0.0/24 -o eth0 -j MASQUERADE
    EOF
  4. 4Enable forwarding and start

    Forwarding lets the VPS route your devices' traffic.

    echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/90-wireguard.conf
    sudo sysctl --system
    sudo systemctl enable --now wg-quick@wg0
    sudo ufw allow 30021/udp
  5. 5Add a device

    Create a key pair for the phone or laptop, add it as a peer and show a QR code for the WireGuard app.

    wg genkey | tee phone.key | wg pubkey > phone.pub
    sudo wg set wg0 peer $(cat phone.pub) allowed-ips 10.66.0.2/32
    sudo wg-quick save wg0
    cat > phone.conf <<EOF
    [Interface]
    PrivateKey = $(cat phone.key)
    Address = 10.66.0.2/32
    DNS = 1.1.1.1
    [Peer]
    PublicKey = $(sudo cat /etc/wireguard/server.pub)
    Endpoint = 203.0.113.10:30021
    AllowedIPs = 0.0.0.0/0, ::/0
    EOF
    qrencode -t ansiutf8 < phone.conf

Speed is limited by your plan's network limit (see the plans table). For more peers repeat the last step with the next address (10.66.0.3, ...).

Your VPS is a few clicks away

Create it in the VPS panel with your Enzonic account. Refunds within 72 hours of payment.

Deploy a VPS