←Back to Knowledge

How to use a VPN account on a router, NAS or Docker, what's inside the config file, and when to run your own WireGuard server. Final part of the series.

Date
Reading
6 min read
Written by
Nick Li
Tags
#Engineering#Risk

Part one followed one web request through a café's Wi-Fi, and part two looked at the company at the other end of the tunnel. This last part is practical: how to use a VPN account without the provider's app, on a router, a NAS or in Docker, what is inside the config file you download, and when it makes more sense to run your own WireGuard server.

Why use a VPN without its app

The app is the easy way, but it protects only the device it runs on, and only devices that can install it. Three situations where people outgrow it:

  • Devices that can't run apps. Smart TVs, printers, a NAS, game consoles. A router with the VPN set up covers all of them at once.
  • One tunnel for a whole room. A small office or a home where every device should leave through the same VPN, without each person remembering to switch it on.
  • One program, not the whole computer. A browser for one task, a script that checks prices in another country, a test server. Running the VPN in a container keeps everything else on the normal connection.

Manual setup: the credentials are not your login

Most paid providers have a page called something like manual setup or router setup. What it gives you depends on the protocol:

What you download for manual setup

  WireGuard   one small text file (.conf)
              that holds your private key

  OpenVPN     one .ovpn file per server
              + a service username and password

The OpenVPN username and password are usually not the email and password you log in with. They are a separate pair made for devices, so a router that leaks them doesn't hand over your account. Still, treat both the WireGuard file and the service password like a password: anyone who has them can use your subscription.

What's inside a WireGuard config

[Interface]
PrivateKey = <your private key: never share>
Address    = 10.5.0.2/32
DNS        = 10.5.0.1

[Peer]
PublicKey  = <the server's public key>
Endpoint   = 203.0.113.10:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
  • PrivateKey is your half of the key pair. The server only knows the matching public key, and the private one never needs to leave your device.
  • Address is your address inside the tunnel, not on the internet.
  • DNS sends name lookups to the provider's server through the tunnel. Leave it out and lookups may go to the café's router instead: the DNS leak from part two.
  • Endpoint is the VPN server's real address and port. UDP 51820 is WireGuard's default.
  • AllowedIPs decides what goes into the tunnel. 0.0.0.0/0 means everything; 192.168.10.0/24 would mean one office network only. More on that below.
  • PersistentKeepalive sends a tiny packet every 25 seconds so routers along the way don't forget the connection.

An OpenVPN file is longer but similar: a remote line with the server, the protocol and port, the certificates that prove the server is genuine, and an auth-user-pass line that asks for the service username and password. The OpenVPN how-to explains each part. WireGuard is newer, far shorter to configure and usually faster, especially on small routers; OpenVPN is older and runs on almost anything. If a device supports both, choose WireGuard.

On a router or NAS

Many routers now have a VPN client page where you upload the file. Two things to check first:

  • Speed. The encryption runs on the router's own processor. A cheap router may manage only a fraction of your broadband speed over OpenVPN; WireGuard does better. Spec sheets often list a VPN speed figure.
  • What happens when the tunnel drops. The app's kill switch isn't there any more. Look for a setting that blocks internet access while the VPN is down, often called kill switch or block non-VPN traffic. Without it, devices quietly fall back to your normal connection.

In a container: one program, one tunnel

For developers and small teams, Docker offers a neat third option. An open-source project such as gluetun runs the VPN connection in a container of its own, using the same manual-setup files and supporting most large providers. Other containers then join its network instead of having one of their own:

One computer, two ways out

  normal browser, email ──── normal connection ───► internet

  ┌ VPN container ──────────────────────────────┐
  │  browser container ─┐                       │
  │  script container  ─┴── tunnel only ────────┼─► internet
  └─────────────────────────────────────────────┘
    firewall: if the tunnel drops, nothing leaves

Anything in that shared network can reach the internet only through the tunnel. The VPN container's firewall blocks everything else, so the kill switch is part of the setup rather than an app setting you hope is on. Add a browser image that you open in an ordinary browser tab, and you get a separate "VPN browser" for one task, with its own cookies and logins, while the rest of the computer behaves as usual. The trade-off: it's a setup to maintain, not an app to click.

Running your own WireGuard

Everything so far uses a provider. The other kind of VPN from part two has none: a WireGuard server in your office or on a cloud server, and one config file per staff laptop. The WireGuard quick start shows the commands; the shape is this:

Your own WireGuard: staff laptop to office

  laptop in a café                 office
  10.8.0.5 ── UDP 51820 ──► router ──► WireGuard server
                                       10.8.0.1
                                          │
                   AllowedIPs = 192.168.10.0/24
                                          ▼
                             NAS, accounts, admin pages
  • One key pair per device. When someone leaves or a laptop goes missing, delete that one peer on the server; nobody else changes anything.
  • Split tunnel. Set AllowedIPs to the office network only. Office traffic goes through the tunnel and everything else goes out normally, so the office line isn't carrying everyone's video calls.
  • One open port. The router forwards UDP 51820 to the server and nothing else. The NAS and admin pages stay off the internet, and WireGuard doesn't reply to packets that aren't signed with a known key, so a scan of your address finds nothing to talk to.

The price is ownership: someone keeps the server updated and manages the keys. Managed services built on WireGuard take that work away for a monthly fee, and for a team with nobody technical they are often the better choice.

One caution: a WireGuard server you rent in the cloud is not a privacy VPN. Its address belongs to you alone, so websites see the same address every time, and the cloud company sits where a VPN provider would. It's for reaching your own systems, not for blending in.

Before you rely on it

  1. Test it. With the tunnel up, open an IP-check site. It should show the VPN's address and country, and DNS servers that aren't your internet provider's.
  2. Pull the plug once. Stop the VPN and check that the device or container loses internet instead of falling back to the normal connection.
  3. Keep the files private. A WireGuard file or service password in a shared folder, a chat or a git repository is a copy of your access.
  4. Update. Routers, NAS boxes and VPN containers need updates like any other software.

That ends the series: what a VPN wraps, who you trust when you use one, and how to put the tunnel where you need it.

A VPN app protects one device. A config file lets you decide which devices, which programs and which networks go through the tunnel.

If you'd like a WireGuard tunnel from your team's laptops to your office, or a VPN set up on a router or in Docker, let's talk.

Further reading