# How do I install WireGuard on my TunnelVPS server?

> Install WireGuard on a TunnelVPS server with apt, make keys, write wg0.conf from a sample with dummy values, start it, then add phones and laptops.

- URL: https://tunnelvps.com/help/install-wireguard-in-one-command/
- Last updated: 2026-11-16
- Publisher: TunnelVPS (https://tunnelvps.com)

**Quick answer — How do I install WireGuard on a TunnelVPS server?**

Log in to the **TunnelVPS** server as root and run `apt install wireguard` on Debian, or `sudo apt install wireguard` on Ubuntu. Then make a key pair, write `/etc/wireguard/wg0.conf`, turn on IP forwarding and start the `wg0` interface. Each device gets its own keys and one `[Peer]` block. The whole setup fits in about 10 commands.

**In brief**

- **Install**: `sudo apt install wireguard` (Ubuntu) or `apt install wireguard` as root (Debian), per wireguard.com.
- **Keys**: `wg genkey | tee privatekey | wg pubkey > publickey`, after `umask 077`.
- **Config**: one `[Interface]` for the server and one `[Peer]` per device.
- **Port**: any free UDP port; TunnelVPS leaves inbound ports open.
- **Clients**: official apps for iOS, Android, Windows and macOS; OpenWrt with `opkg install wireguard`.

## Which command installs WireGuard on each TunnelVPS image?

**The same package name on all four images; only the `sudo` prefix differs.** TunnelVPS read WireGuard's install page on 16 November 2026.

*WireGuard install command for each TunnelVPS system image, from wireguard.com, read 16 November 2026*

| TunnelVPS image | Install command | Note from wireguard.com |
| --- | --- | --- |
| Ubuntu 24.04 LTS | `sudo apt install wireguard` | Ubuntu command as published |
| Ubuntu 22.04 LTS | `sudo apt install wireguard` | Ubuntu command as published |
| Debian 13 | `apt install wireguard` | Run as root |
| Debian 12 | `apt install wireguard` | Run as root; backports only for releases older than Bullseye |

## How do you install the package and make the server keys?

**Update the package list, install, then create the key pair inside `/etc/wireguard`.** You log in as root, so `sudo` is optional. The [first SSH login guide](https://tunnelvps.com/help/first-ssh-login/ "How do I log in to a TunnelVPS server over SSH?") covers getting that far.

*Install WireGuard and create the server key pair*

```bash
apt update
apt install wireguard
cd /etc/wireguard
umask 077
wg genkey | tee privatekey | wg pubkey > publickey
cat privatekey publickey
```

## What goes in wg0.conf?

**An `[Interface]` section for the server, then one `[Peer]` section per device.** The sample below uses obvious dummy values. Replace every word in capitals with a real key from your server or device.

- **Address** is the server's address inside the tunnel, here `10.8.0.1/24`.
- **ListenPort** is the UDP port devices connect to. 51820 is common; any free port works.
- **PostUp and PostDown** let tunnel traffic out to the internet. Replace `eth0` with the name shown after `dev` in `ip route`.
- **AllowedIPs** under each peer is that device's own tunnel address, one per device.

On Debian, install `iptables` with apt first if the command is missing.

*/etc/wireguard/wg0.conf (sample with dummy values)*

```ini
[Interface]
Address = 10.8.0.1/24
ListenPort = 51820
PrivateKey = SERVER_PRIVATE_KEY_HERE
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]
# phone
PublicKey = PHONE_PUBLIC_KEY_HERE
AllowedIPs = 10.8.0.2/32

[Peer]
# laptop
PublicKey = LAPTOP_PUBLIC_KEY_HERE
AllowedIPs = 10.8.0.3/32
```

## How do you turn on forwarding and start the tunnel?

**Allow the kernel to forward packets, then start `wg0` and set it to start at boot.** `wg show` then lists the interface and, once devices connect, each peer with its latest handshake and bytes sent and received.

If you enabled a firewall such as ufw, open the WireGuard port in it. Inbound UDP and TCP ports are open on the server; the customer chooses the VPN port and sets the firewall.

*Enable forwarding and start WireGuard*

```bash
echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/99-wireguard.conf
sysctl --system
systemctl enable --now wg-quick@wg0
wg show
```

## How do you add a phone or a laptop?

**Make a key pair for the device, add its public key as a `[Peer]` on the server, and give the device a client file.** Run the same `wg genkey` line in a separate folder for each device. After editing `wg0.conf`, restart with `systemctl restart wg-quick@wg0`.

The client file below points at the server. `203.0.113.10` is a documentation address: put your server's IPv4 there, as shown in the dashboard. `AllowedIPs = 0.0.0.0/0` sends all IPv4 traffic through the tunnel.

Each device guide shows how to import the file. Start with the [guides hub](https://tunnelvps.com/guides/ "Which WireGuard setup guide fits my device?"), which links iPhone, Android, Windows, macOS and routers. The [iPhone guide](https://tunnelvps.com/guides/wireguard-iphone/ "How do I set up WireGuard on an iPhone?") is the most detailed.

*phone.conf, the client file (sample with dummy values)*

```ini
[Interface]
PrivateKey = PHONE_PRIVATE_KEY_HERE
Address = 10.8.0.2/32
DNS = DNS_RESOLVER_IP_HERE

[Peer]
PublicKey = SERVER_PUBLIC_KEY_HERE
Endpoint = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
```

## What should you keep a copy of?

**The `/etc/wireguard` folder, off the server.** No plan includes backups; daily backups kept 7 days can be added at checkout for 15% of the plan price. Without them, keep a copy of the VPN configuration and keys off the server. Reboot, reinstall and delete are sent from the dashboard and carried out by a person; a reinstall erases the disk, VPN keys included.

With a copy of `wg0.conf` and the server keys, a reinstalled server takes the same configuration back, and devices reconnect without new files. If WireGuard is blocked on a network you use, the [WireGuard VPS page](https://tunnelvps.com/wireguard-vps/ "Where can I rent a VPS for my own WireGuard VPN?") points to AmneziaWG and Outline.

## WireGuard install questions

### Does TunnelVPS offer a server with WireGuard already set up?

No. A ready-made VPN image is not offered today; the four Debian and Ubuntu images are the systems Amnezia lists as officially supported for its self-hosted server. The install takes the commands on this page.

### Which port should I use?

Any free UDP port. The sample uses 51820; the same number goes in `ListenPort` on the server and in `Endpoint` on each device.

### Can I add IPv6 to the tunnel?

Yes. Each server has a routed IPv6 /64. Add an IPv6 tunnel address and `::/0` to the client's AllowedIPs once IPv6 forwarding is set up.

### Is there a web panel instead of config files?

wg-easy runs WireGuard with a web admin page in Docker, under the AGPL-3.0 licence. Docker installs with `curl -sSL https://get.docker.com | sh`, then follow the wg-easy docs.

### How do I see which devices are connected?

Run `wg show`. Each peer shows its latest handshake and the bytes received and sent.

**Verdict**

- **One command installs WireGuard** on every TunnelVPS image; keys, `wg0.conf` and forwarding finish the job.
- **Keep `/etc/wireguard` backed up off the server**, since a reinstall erases it.

## Sources

1. [Installation](https://www.wireguard.com/install/) — WireGuard (read 2026-11-16)
2. [Quick Start](https://www.wireguard.com/quickstart/) — WireGuard (read 2026-11-16)
3. [Protocol & Cryptography](https://www.wireguard.com/protocol/) — WireGuard (read 2026-11-16)
4. [wg-easy](https://github.com/wg-easy/wg-easy) — GitHub (read 2026-11-16)
5. [IPv4 Address Blocks Reserved for Documentation (RFC 5737)](https://www.rfc-editor.org/rfc/rfc5737) — IETF (January 2010)

**Need a server for WireGuard?** Solo covers one person for $2.25 a month on 12 months. [Order Solo for 12 months](https://tunnelvps.com/app/checkout/?plan=solo&term=12m&from=help-install-wireguard-in-one-command&lang=en) · [All help pages](https://tunnelvps.com/help/ "Where do I find help with a TunnelVPS server?")

---

TunnelVPS: TunnelVPS rents Linux KVM servers for a personal VPN (WireGuard, Outline or AmneziaWG) in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID document. 5 plans from 2 to 16 GB of RAM and 2 to 6 TB of traffic a month cost the same in all six cities; on the 12-month term each is priced at least 25% under a named comparable plan of a no-KYC crypto host, read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
