Skip to content
CryptoDedicated
Menu

How do I set up a WireGuard VPN server on a dedicated server?

How to set up a WireGuard VPN server on a Debian or Ubuntu dedicated machine, with full-tunnel clients and NAT through nftables.

Updated , by the CryptoDedicated team, 6 min read

Quick answer

How do I set up a WireGuard VPN server on a dedicated server?

Install wireguard, create a server key pair, describe the tunnel in /etc/wireguard/wg0.conf (a private subnet, UDP 51820), turn on forwarding and masquerading, then bring it up with wg-quick@wg0, one peer per device. On a CryptoDedicated Ryzen 5600 with a 1 Gbit/s port, that takes about 10 minutes; the machine costs $83.69 per 30 days in Monero.

In brief
  • One UDP port: WireGuard listens on 51820 by default; open it in the firewall and nothing else changes.
  • Keys, not passwords: each side has a private key and shares only its public key.
  • Forwarding and NAT: net.ipv4.ip_forward=1 plus one nftables masquerade rule send client traffic out through the server IP.
  • One peer block per device: a phone, a laptop and a router each get their own key and tunnel address.
  • Exit country: Amsterdam, Reykjavik, Zurich or Bucharest, picked at checkout at one identical price.

What goes in the server and client configuration files?

Seven fields make a working full-tunnel WireGuard setup; the AllowedIPs line is the one that decides what the tunnel carries.

WireGuard configuration fields for a full-tunnel VPN on a CryptoDedicated server, server side and client side
FieldServer (wg0.conf)Client (laptop.conf)
PrivateKeyContent of srv.privContent of the client's own key
Address10.66.66.1/2410.66.66.2/32
ListenPort51820Not set (random)
PublicKey (in [Peer])The client's public keyContent of srv.pub
AllowedIPs (in [Peer])10.66.66.2/32: the client's tunnel address0.0.0.0/0, ::/0: send everything through the tunnel
EndpointNot setSERVER-IP:51820
PersistentKeepaliveNot set25, keeps the NAT mapping alive behind home routers

How do I build the WireGuard server step by step?

  1. Install the tools

    apt install wireguard on any of the Debian or Ubuntu images; the kernel module is already in the stock kernel.

  2. Generate the server keys

    With umask 077, pipe wg genkey into wg pubkey and keep the two files in /etc/wireguard.

  3. Find the outgoing interface

    ip route show default prints the interface name (for example eno1 or enp5s0) used in the NAT rule.

  4. Write wg0.conf

    Interface block with the server key, 10.66.66.1/24 and port 51820, then one Peer block per client.

  5. Enable forwarding and NAT

    Put the forwarding switch, net.ipv4.ip_forward, in its own sysctl.d file, reload with sysctl --system, and load a masquerade rule with nft.

  6. Start the tunnel

    systemctl enable --now wg-quick@wg0, then open UDP 51820 in the firewall.

  7. Import the client file

    Import laptop.conf into the WireGuard app, or print a scannable code in the terminal with qrencode -t ansiutf8, and check the handshake with wg show.

Tunnel keys, wg0.conf, forwarding and masquerading on Debian 13 (eno1 and the laptop key are examples)
apt install -y wireguard qrencode
umask 077 && mkdir -p /etc/wireguard/keys && cd /etc/wireguard/keys
# one pair for the server, one per device
wg genkey > srv.priv && wg pubkey < srv.priv > srv.pub
wg genkey > laptop.priv && wg pubkey < laptop.priv > laptop.pub
ip -brief route get 1.1.1.1      # the "dev" field is the uplink, e.g. eno1

printf "[Interface]\nAddress = 10.66.66.1/24\nListenPort = 51820\nPrivateKey = %s\n\n[Peer]\n# laptop\nPublicKey = %s\nAllowedIPs = 10.66.66.2/32\n" \
  "$(cat srv.priv)" "$(cat laptop.pub)" > /etc/wireguard/wg0.conf

# routing between the tunnel and the uplink
printf "net.ipv4.ip_forward = 1\n" > /etc/sysctl.d/60-vpn.conf && sysctl --system
nft -f - <<'RULES'
table ip vpnnat {
  chain post { type nat hook postrouting priority srcnat; ip saddr 10.66.66.0/24 oifname "eno1" masquerade; }
}
RULES

systemctl enable --now wg-quick@wg0 && wg show wg0
Device file laptop.conf (scan it on a phone with qrencode -t ansiutf8 < laptop.conf)
[Interface]
# contents of laptop.priv
PrivateKey = LAPTOP_PRIVATE_KEY
Address = 10.66.66.2/32
DNS = 1.1.1.1

[Peer]
# contents of srv.pub
PublicKey = SERVER_PUBLIC_KEY
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 203.0.113.10:51820
PersistentKeepalive = 25

Why put a WireGuard server on dedicated hardware?

Encryption runs on cores that no other customer shares, so throughput stays steady at the 1 Gbit/s port speed instead of dropping at a neighbour's peak. WireGuard is light: a single modern core handles gigabit traffic, so even the Ryzen 5600 has spare cores for a DNS resolver, a web server or a node.

The 40 TB a month at 1 Gbit/s included covers a household or a small team many times over. Sizing for larger groups is covered in the VPN server use case. According to CryptoDedicated's survey of 30 October 2026, 82% of dedicated-server sellers took some form of cryptocurrency, but few let the buyer skip both ID and email.

What stays private behind a self-run VPN, and what stays visible?

Café Wi-Fi, the local network and the home ISP lose sight of the traffic; websites then see the server's IP address, registered to the datacenter. The server itself sees every connection the clients make, which is the point of running it yourself rather than trusting a VPN company.

What stays true on a CryptoDedicated machine:

  • the account holds the data billing needs, listed on the data collected page;
  • outbound port 25 is closed, so mail clients behind the tunnel must send on 465 or 587;
  • abuse reports about traffic leaving the IP are handled under the acceptable use policy, whoever generated it.

How do I keep the VPN server locked down?

Leave only SSH and UDP 51820 open, and drop everything else inbound. A WireGuard port does not answer packets without a valid key, so scanners cannot even confirm it is there.

The complete ruleset, with the input chain, the forward chain for 10.66.66.0/24 and the NAT table in one file, is in the nftables firewall guide. Rules added with nft add vanish at reboot, so move them into /etc/nftables.conf once the tunnel works.

Frequently asked questions

Is running a VPN allowed on CryptoDedicated servers?

Yes, for personal or team use and for services that respect the acceptable use policy. Traffic that leads to confirmed abuse reports gets the machine suspended, whoever sent it.

How many WireGuard clients can one server handle?

Hundreds of peers are routine; the practical limit is the 1 Gbit/s port shared by active users, not the CPU.

Can clients get IPv6 through the tunnel?

Yes. Every machine has an IPv6 /64; give the tunnel a subnet from it, set net.ipv6.conf.all.forwarding=1, and list ::/0 in the client's AllowedIPs.

Which exit country should I pick?

Choose by latency and law: Amsterdam and Bucharest sit inside the EU, Reykjavik inside the EEA only, Zurich in neither. The price is identical in all four cities.

Verdict
  • CryptoDedicated is the better pick for a private WireGuard server paid in crypto: whole cores, a 1 Gbit/s port and four European exit cities from $83.69.
  • Pick a commercial VPN if rotating many countries matters more than controlling the server.
  • Keys per device, one UDP port, rules saved to nftables.conf: that is the full maintenance list.
Sources (4)
  1. Quick start — WireGuard (read 2026-11-30)
  2. wg(8) — Linux man-pages (read 2026-11-30)
  3. WireGuard — Debian Wiki (read 2026-11-30)
  4. Performing Network Address Translation (NAT) — nftables wiki (read 2026-11-30)

A WireGuard server with its own cores

Ryzen 5600, 6 cores / 12 threads, 40 TB a month at 1 Gbit/s: $83.69 per 30 days in crypto.

Read next

$83.69 Ryzen 5600, per 30 days

Order