A wireguard vpn homelab remote access setup lets you reach your home server from anywhere as if you were on your home network. You can open dashboards, copy files, and manage services without exposing each service to the internet. WireGuard fits this job well because it is small, fast to set up, and easy to keep running once the tunnel works.
This guide walks through a complete wireguard vpn setup on Ubuntu or Debian. You will install WireGuard on a server at home, create keys, write a server config, add one peer, open the firewall, forward one UDP port, and connect from a laptop or phone. The same steps work on a mini PC, an old laptop, or a virtual machine. If you are still planning hardware, read this guide to what you actually need for a homelab starter build before you buy anything else.
What you need before you start
You need a Linux server that stays on at home, a router you can log in to, and a client device such as a laptop or phone. The server can run Ubuntu 22.04, Ubuntu 24.04, or Debian 12. Note the server local IP address, for example 192.168.1.10, and your home public IP address, which you can find with curl ifconfig.me.
Pick UDP port 51820, the WireGuard default. Pick a tunnel subnet that does not clash with your home network or networks you connect from. If your home network is 192.168.1.0/24, use 10.6.0.0/24 for the tunnel. The server takes 10.6.0.1 and the first peer takes 10.6.0.2.
Install WireGuard on the server
Install WireGuard and its tools with apt.
sudo apt update
sudo apt install wireguard wireguard-tools -y
Enable IP forwarding so the server can pass traffic between the tunnel and your home network. Add both lines, then apply the change.
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.all.forwarding=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
WireGuard VPN Homelab Remote Access Server Config
Generate a key pair for the server. Keep the private key on the server and never share it. The public key is safe to share with peers.
cd /etc/wireguard
umask 077
wg genkey | sudo tee privatekey | wg pubkey | sudo tee publickey
sudo cat publickey
Write down the server public key for the peer config later. Now create /etc/wireguard/wg0.conf. Replace the private key with the one you just made. Check your interface name with ip a first. It is often eth0 or enp0s3.
[Interface]
PrivateKey = YOUR_SERVER_PRIVATE_KEY
Address = 10.6.0.1/24
ListenPort = 51820
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 = YOUR_LAPTOP_PUBLIC_KEY
AllowedIPs = 10.6.0.2/32
The PostUp and PostDown lines add NAT rules when the tunnel starts and remove them when it stops, so tunnel traffic can reach your LAN and get replies back.
Generate keys and add a peer
A wireguard server setup needs one key pair per peer. Each laptop, phone, or desktop gets its own keys and tunnel address, so you can remove one device later without changing keys on the others.
Generate the client keys on the client device, or generate them on the server and copy the private key to the client over a safe channel. Do not send a private key by plain email or chat.
wg genkey | tee laptop-privatekey | wg pubkey | tee laptop-publickey
cat laptop-publickey
Put the laptop public key in the [Peer] section of /etc/wireguard/wg0.conf and give the laptop address 10.6.0.2. The next peer gets 10.6.0.3.
Now write the client config. It goes on the laptop, not the server. Replace the private key, the server public key, and the endpoint with your own values. The endpoint is your home public IP and port, for example 203.0.113.10:51820. If you have a domain that points to your home IP, use that instead, so it keeps working if your IP changes.
[Interface]
PrivateKey = YOUR_LAPTOP_PRIVATE_KEY
Address = 10.6.0.2/24
DNS = 192.168.1.1
[Peer]
PublicKey = YOUR_SERVER_PUBLIC_KEY
Endpoint = YOUR_PUBLIC_IP_OR_DOMAIN:51820
AllowedIPs = 192.168.1.0/24, 10.6.0.0/24
PersistentKeepalive = 25
The client AllowedIPs line controls which traffic uses the tunnel. The example sends only home LAN and tunnel traffic through WireGuard and leaves normal internet traffic alone. That is split tunneling. To send all traffic through home instead, set AllowedIPs = 0.0.0.0/0, ::/0, but expect slower speeds when you are far from home. PersistentKeepalive = 25 sends a small packet every 25 seconds so the connection stays open through NAT.
Open the firewall and forward the port
Allow UDP port 51820 through the server firewall. With UFW, run:
sudo ufw allow 51820/udp
sudo ufw status
With firewalld, run:
sudo firewall-cmd --permanent --add-port=51820/udp
sudo firewall-cmd --reload
Next, forward UDP port 51820 on your router to the server local IP, for example 192.168.1.10. Log in to the router, open the port forwarding page, add a UDP 51820 rule, and point it at the server. WireGuard uses UDP only, so a TCP rule will not work. Give the server a fixed local IP with a DHCP reservation in the router, so the forward does not break after a reboot.
Start WireGuard and test the tunnel
Start the tunnel on the server and set it to start on boot:
sudo systemctl enable --now wg-quick@wg0
sudo wg show
The output should show wg0, the listening port, and the peer. Import the client config on your laptop or phone. On Linux, save it as /etc/wireguard/wg0.conf and run sudo wg-quick up wg0. On Windows, macOS, Android, and iOS, import the file in the WireGuard app. For a phone, you can make a QR code from the config with qrencode -t ansiutf8 < /etc/wireguard/laptop.conf after installing qrencode.
Test from the client away from home, or from your phone with Wi-Fi off. First ping the server tunnel address, then ping a device on your home LAN and open a service dashboard by its local address, for example http://192.168.1.10:8080.
ping 10.6.0.1
Run sudo wg show on the server. A recent handshake and growing transfer counters mean the tunnel works. If you run services behind a reverse proxy, the setup in this guide to reverse proxies and Nginx pairs well with WireGuard, because the proxy stays private while the VPN controls who can reach it.
Common mistakes and how to fix them
Most WireGuard problems come from a short list of errors. Work through them in order instead of changing five things at once.
- No handshake at all: check the port forward, the firewall rule, and the endpoint. The client must point at the current public IP or domain, on UDP 51820.
- Handshake works but nothing loads: check IP forwarding and NAT on the server. Run
sysctl net.ipv4.ip_forwardand confirm it returns 1, and check thePostUpinterface name matches your real interface. - Keys in the wrong place: the server config holds the server private key and the peer public key. The client config holds the client private key and the server public key. A swapped key fails with no handshake.
- Wrong AllowedIPs: if the client cannot reach the LAN, its
AllowedIPsmay not include your LAN subnet. If the client loses all internet, it may have0.0.0.0/0set with a broken DNS or NAT path. - Address clash: the tunnel subnet must not match your home LAN or the network you connect from. A tunnel subnet such as 10.6.0.0/24 avoids most clashes.
- Peer address reuse: two peers with the same tunnel address fight over the route. Give each peer its own address.
- Wrong server time: handshakes depend on correct time. If the server clock is far off, enable time sync and check the date.
Check sudo journalctl -u wg-quick@wg0 on the server for errors when the service starts. Keep a backup of /etc/wireguard/wg0.conf in a safe place, because it holds private keys and peer entries that are painful to rebuild from memory.
Remote homelab access after the tunnel works
Once the tunnel is up, remote homelab access feels like being at home. You can reach Proxmox, a NAS, Home Assistant, or a media server by local address, and run admin tasks over SSH without opening SSH to the internet. If you run Proxmox, follow this step-by-step Proxmox VE 8 install on a mini PC to build the host, then use WireGuard as the only way in from outside. Close any port forwards you opened for single services and keep only the WireGuard UDP port open.
Review peers every few months. Remove devices you no longer use, rotate keys for a device you lost, and check the server still starts on boot after updates. For a fuller plan of what to build next, see this first-homelab hardware checklist for 2026.