WireGuard VPN at Home: Set Up wg-easy With Docker

14 min read

,
WireGuard VPN at Home: Set Up wg-easy With Docker

A WireGuard VPN at home lets you reach your NAS or home server while you are away. Run wg-easy on an always-on Linux machine and it handles client configurations through a web interface. Your router forwards one UDP port to the server; a full-tunnel client can also route browsing through your home connection.

Check that your home connection has a reachable public IP before installing anything. CGNAT prevents ordinary inbound IPv4 port forwarding, while double NAT can require changes on two routers. The setup below uses wg-easy v15, Docker Compose and an SSH connection for the admin page.

Why run your own WireGuard VPN?

A home VPN does two jobs:

  • Remote access. Open your NAS, Home Assistant, Jellyfin or router admin page from your phone on mobile data as if you were at home, without exposing any of those services to the internet.
  • Safer public Wi-Fi. With a full-tunnel profile, traffic routed through the VPN is encrypted between your device and home. Websites still need HTTPS beyond that connection, and your home ISP still carries the traffic.

WireGuard is the protocol to use for this. It is built into the Linux kernel, uses modern cryptography, reconnects quickly when your phone switches between Wi-Fi and mobile data, and is light enough for a Raspberry Pi to handle easily. What WireGuard does not have on its own is a friendly way to manage keys and devices. That is the gap wg-easy fills: it generates keys, assigns addresses, builds client configs and shows who is online.

wg-easy or the alternatives?

Before you start, make sure wg-easy is the right tool for your connection and comfort level.

OptionNeeds a public IPNeeds port forwardingSetup effortBest for
wg-easy (this guide)YesYes, UDP 51820Low to mediumSelf-hosted server and client management
TailscaleNoNoLowestCGNAT connections, quick multi-device access
Router with built-in WireGuardYesHandled by routerLowRouters that already support it
Plain WireGuard with wg-quickYesYesHighPeople comfortable editing config files by hand
OpenVPNYesYesMedium to highOlder devices without WireGuard support

If your connection is behind CGNAT, Tailscale is a practical alternative for network access. Cloudflare Tunnel is another option for publishing specific services, but it is not a drop-in full-tunnel WireGuard VPN. Our guide to accessing a home server behind CGNAT covers both. Some newer routers also have WireGuard built in, which our Wi-Fi 7 router guide touches on, while wg-easy is useful when you want to manage clients on a separate Linux server.

Step 0: Check whether you have a public IP

This takes two minutes and saves an evening of frustration.

  1. Log in to your router’s admin page and find the WAN IP or Internet IP on the status page.
  2. On a device at home, search “what is my IP” in a browser and note the public IPv4 address it shows.
  3. Compare the two.

If they match, your router has a public IPv4 address. You still need working port forwarding and firewall rules, and your ISP must allow inbound traffic. If the router’s WAN IP starts with 100.64 to 100.127, 10., 172.16 to 172.31 or 192.168., or does not match the public address, you are behind CGNAT or double NAT. Some ISPs will assign a public IP on request or sell a static IP as a paid add-on, so it is worth asking support before giving up.

Decision graphic comparing a router's WAN IP with a what-is-my-IP result: matching addresses mean a public IP and wg-easy will work; a mismatch or a WAN IP in 100.64 to 100.127, 10., 172.16 to 172.31, or 192.168. means CGNAT or double NAT
Image: Techzei

Most home connections also get a dynamic public IP that changes from time to time. wg-easy needs a hostname that always points at your current IP, so set up a free dynamic DNS name. Many routers have DDNS built in under the WAN or DDNS settings. Use that hostname wherever this guide says host.

What you need before you start

  • An always-on Linux machine on your home network. A Raspberry Pi 4 or 5 running 64-bit Raspberry Pi OS is ideal. wg-easy supports x86_64 and arm64. If you already run a home server or a Proxmox box, use that.
  • A public IP and a DDNS hostname (Step 0).
  • Router admin access to create a port forward.
  • Docker Engine 28 or newer with the Compose plugin, installed in Step 1, plus SSH access to the server.
  • The WireGuard app on each client: Android, iPhone, Windows, macOS and Linux all have official apps from wireguard.com.

Give the server a fixed local IP address, either in its network settings or as a DHCP reservation in your router. The port forward in Step 4 points at that address, and it breaks if the address changes.

Step 1: Install Docker

wg-easy’s own guide points to Docker’s official install instructions. On Raspberry Pi OS or Debian, Docker’s convenience script installs Docker Engine and the Compose plugin in one go:

curl -sSL https://get.docker.com | sh

Confirm that Compose is available:

sudo docker compose version

For the manual repository method, follow Docker’s installation instructions for your distribution. Either way, you need Docker Compose v2, which uses docker compose with a space.

Step 2: Download and start wg-easy

wg-easy’s basic installation tutorial uses /etc/docker/containers/wg-easy as its folder. Create it and download the official Compose file:

sudo mkdir -p /etc/docker/containers/wg-easy
sudo curl -o /etc/docker/containers/wg-easy/docker-compose.yml https://raw.githubusercontent.com/wg-easy/wg-easy/master/docker-compose.yml

The file pulls ghcr.io/wg-easy/wg-easy:15, publishes UDP port 51820 for WireGuard and TCP port 51821 for the web interface, adds the NET_ADMIN and SYS_MODULE capabilities WireGuard needs, enables IP forwarding through sysctls, and stores everything in a named volume called etc_wireguard.

Keep the :15 tag. It tracks the latest v15 release without breaking changes. Do not switch to :latest, which is not the tag the project recommends for v15.

Keep the admin page on the server

The admin page controls access to your home network. Bind its port to the server’s loopback address and open it through SSH from your computer. The VPN itself still listens on UDP 51820.

sudo nano /etc/docker/containers/wg-easy/docker-compose.yml

Under services: wg-easy:, uncomment environment:, set INSECURE=true, and replace the existing ports: entries with these. Keep the rest of the downloaded file, including its volumes, network and forwarding settings.

    environment:
      - INSECURE=true
    ports:
      - "51820:51820/udp"
      - "127.0.0.1:51821:51821/tcp"

INSECURE=true permits HTTP inside this arrangement; SSH encrypts the connection between your computer and the server. Do not leave the original "51821:51821/tcp" mapping in place as well. Docker Engine 28 or newer avoids an older localhost-publishing issue. For browser access without SSH, follow wg-easy’s official HTTPS reverse-proxy instructions instead.

Start the container

cd /etc/docker/containers/wg-easy
sudo docker compose up -d

Check that it is running:

sudo docker compose ps
sudo docker compose logs -f wg-easy

Press Ctrl+C to leave the logs. Always use docker compose up -d and docker compose down with wg-easy rather than start and stop, as the project recommends, so network and configuration changes apply properly.

Step 3: Run the setup wizard

On your computer, open an SSH tunnel to the server. Replace your-user and SERVER-IP with your SSH login and the server’s local IP address:

ssh -N -L 127.0.0.1:51821:127.0.0.1:51821 your-user@SERVER-IP

Leave that terminal open and visit http://127.0.0.1:51821 in your computer’s browser. Ctrl+C closes the SSH tunnel when you finish. A phone cannot open this loopback-only admin page directly.

  1. On the welcome screen, select Continue.
  2. Create the admin account. Use a unique, long password. Select Create Account, and store the password in your password manager.
  3. When asked whether you have an existing setup, choose No.
  4. Enter the Host: your DDNS hostname or public IP. The Suggest button can fill in a detected address, but a DDNS name is better on a dynamic connection.
  5. Keep the Port at 51820 unless you changed it in the Compose file.
  6. Finish the wizard and sign in.

If you are deploying several servers or prefer configuration as code, wg-easy also supports an unattended setup through INIT_ environment variables such as INIT_ENABLED, INIT_USERNAME, INIT_PASSWORD, INIT_HOST and INIT_PORT. For a single home server, the wizard is quicker.

wg-easy web interface listing WireGuard clients with their addresses, traffic and online status
wg-easy lists each client separately so access can be revoked per device. Image: wg-easy

Step 4: Forward UDP port 51820 on your router

Every router names this slightly differently. Look for Port Forwarding, Virtual Server or NAT in the advanced settings.

  • Protocol: UDP
  • External port: 51820
  • Internal IP: the server’s fixed local IP
  • Internal port: 51820

Forward only UDP 51820. Do not forward 51821, the web interface port. If the server runs its own firewall, such as ufw, open the same UDP port there too:

Network path diagram of a WireGuard connection: a phone on mobile data, across the internet, to the home public IP, a router port forward of UDP 51820, the wg-easy server's fixed local IP on port 51820, then into home LAN devices. Forward only UDP 51820, not the web interface port 51821
Image: Techzei
sudo ufw allow 51820/udp

Step 5: Add your first device

  1. In wg-easy, select New Client.
  2. Give it a clear name, such as jash-phone or office-laptop. Optionally set an Expires At date for temporary access, for example a guest.
  3. Select Create Client.
  4. On your phone, install the official WireGuard app, tap the add button and choose to scan a QR code. Then show the client’s QR code in wg-easy.
  5. Name the tunnel and allow the app to add a VPN configuration.

For laptops, download the client’s configuration file from wg-easy and import it into the WireGuard app. Treat both the QR code and the downloaded file as credentials: anyone with a copy can use that client’s access.

WireGuard iOS app showing a list of tunnels with on and off toggles
Enable the imported tunnel in the WireGuard app. Image: WireGuard

Create one client per device rather than sharing a config. That way you can revoke a lost phone without touching anything else.

Step 6: Test it from outside your network

Test from mobile data so you can verify the router’s inbound path, rather than only local connectivity.

  1. Turn off Wi-Fi on your phone and use mobile data.
  2. Turn the tunnel on in the WireGuard app.
  3. Open a service that only exists at home, such as your NAS or Home Assistant, using its local IP address. The wg-easy admin port is loopback-only in this setup.
  4. Search “what is my IP” again. With a full-tunnel client, it should show your home IP rather than your mobile network’s. Check both IPv4 and IPv6 if your connection supports them.

In wg-easy, the client should now show as online, which means it completed a handshake in the last 10 minutes. You can confirm the same thing from the server with WireGuard’s own tool:

sudo docker exec wg-easy wg show

A recent latest handshake confirms peer connectivity. Growing transfer counters and a successful request to a home service confirm that useful traffic crosses the tunnel.

Terminal output of wg show listing the WireGuard interface, peers, latest handshake and transfer totals
A recent handshake shows that the WireGuard peers can communicate. Image: WireGuard

WireGuard’s own walkthrough shows the same idea from the other side: once a ping crosses the tunnel, wg reports the peer’s endpoint and a handshake a few seconds old.

Terminal showing a successful ping across a WireGuard tunnel followed by wg output with peer endpoint and latest handshake
Test traffic as well as the handshake before relying on the tunnel. Image: WireGuard

Step 7: Choose routing and DNS

Check the settings in your installation rather than assuming an older guide uses the same defaults. The Admin Panel manages server settings; open an individual client to change its routes, DNS and advanced connection settings. These examples explain what the values mean:

SettingExample valueWhen to change it
VPN address range10.8.0.0/24 (example VPN subnet)Only if it clashes with a network you already use
Client DNS1.1.1.1Point it at your Pi-hole to block ads on the go
Allowed IPs0.0.0.0/0, ::/0 (full tunnel)Set to your home subnet for split tunnelling
MTU1420Lower it if some sites hang on certain mobile networks
Persistent keepalive0 (off)Set to 25 if clients drop behind strict NAT
Preshared keysOnLeave on for an extra layer of key security

Full tunnel or split tunnel. With full-tunnel Allowed IPs, matching IPv4 and IPv6 traffic is routed through your home connection. That is what you want on public Wi-Fi, but it uses your home upload speed and adds latency. If you only want access to home devices, change Allowed IPs to your home subnet and the VPN range, for example 192.168.1.0/24, 10.8.0.0/24. Normal browsing then goes direct over mobile data. Include your local DNS server’s subnet if you use one, and re-export and re-import the client configuration after changing its routes. Check for a subnet clash if the network you are visiting also uses 192.168.1.0/24.

Routes are not permissions. A client’s Allowed IPs control what it sends into the tunnel. They do not prevent someone from editing their own configuration to reach other home devices. Use server-side firewall rules for access restrictions, and test those rules before granting access to a guest.

Ad blocking everywhere. If you run Pi-hole at home, set the client DNS to your Pi-hole’s local IP and your phone gets the same ad and tracker blocking on mobile data. Our Pi-hole and Unbound setup guide covers the DNS side.

Enable two-factor authentication for the admin account and store its recovery details safely.

Connect automatically when you leave home

The WireGuard apps for iPhone and Mac support on-demand rules: connect automatically on mobile data or on any Wi-Fi network except your home one. In the iOS app, edit the tunnel, turn on On-Demand for cellular and Wi-Fi, and exclude your home network name.

WireGuard iOS tunnel details screen with On-Demand activation options
On-demand rules can activate the tunnel automatically. Image: WireGuard
WireGuard iOS on-demand SSID rules to connect except on selected Wi-Fi networks
Exclude your trusted home Wi-Fi from an on-demand connection rule. Image: WireGuard

On Android, use the system’s Always-on VPN setting for the WireGuard app if you want the tunnel up permanently.

Keep wg-easy updated and backed up

From the wg-easy folder, pull the updated image and recreate the container:

cd /etc/docker/containers/wg-easy
sudo docker compose pull
sudo docker compose up -d

All configuration, including the admin account, keys and clients, lives in the etc_wireguard Docker volume. Stop the stack with sudo docker compose down before taking a filesystem copy of the actual named volume, then bring it back with sudo docker compose up -d. The volume’s full name can include the Compose project prefix. Never add -v to down, because that removes named volumes. Keep an encrypted copy off the server. Losing it means recreating and redistributing every client configuration. If you already run a backup tool for your home server, add that volume to it.

Troubleshooting

The client never shows as online. Check in this order: the port forward is UDP (not TCP) to the right local IP; the server’s firewall allows UDP 51820; the Host in wg-easy matches your current public IP or DDNS name; and your connection is not behind CGNAT (Step 0).

It connects but nothing loads. IP forwarding or DNS is the usual cause. Restart with sudo docker compose down and sudo docker compose up -d so the sysctls apply, and test with the DNS set to 1.1.1.1 to rule out a local DNS problem.

Works on Wi-Fi elsewhere but not on mobile data. If the handshake succeeds but larger requests hang, try a lower client MTU, such as 1280, then re-import the configuration. A missing handshake points first to the endpoint, firewall or UDP path, rather than MTU.

The web interface says insecure access is not allowed. Check INSECURE=true and the loopback-only port mapping in Step 2, then recreate the container with sudo docker compose up -d. For this setup, open the page through the SSH tunnel.

It stopped working after a few days. Your public IP changed and the Host still points at the old one. Use a DDNS hostname as the Host. If an existing client still uses the old resolved address, toggle its tunnel off and on to resolve the hostname again.

You see an older interface or settings are missing. Check the image tag in the Compose file. It should be ghcr.io/wg-easy/wg-easy:15.

Worth considering

A Raspberry Pi makes an ideal low-power VPN server that you can leave running next to your router. Prices change often on Amazon India, so check the listing before buying.

Disclosure: Techzei earns a commission from qualifying purchases made through Amazon links on this page, at no extra cost to you. This does not affect which products we list.

FAQ

Does wg-easy work on Jio or Airtel fibre?

It works if your connection has a public IP. Many plans are behind CGNAT by default, which blocks incoming connections. Compare your router’s WAN IP with your public IP, and if they differ, ask your ISP for a public or static IP or use Tailscale instead.

Is a home WireGuard VPN the same as a commercial VPN?

No. A commercial VPN hides your traffic behind the provider’s servers in other countries. A home VPN sends your traffic through your own home connection, so websites see your home IP. It is for reaching your home network and staying safe on public Wi-Fi, not for changing your country.

What happens if my home internet goes down?

The tunnel stops carrying traffic. A full-tunnel client may lose internet access until the connection returns or you disable the tunnel. An always-on or block-without-VPN setting can keep traffic blocked. A small UPS for the router and server helps with short power cuts.

About the author