KORTHVEILSecurity firewall
Guides

WireGuard remote access in five minutes: a QR code or a file for each device

Download as PDF All guides

The Remote-access VPN wizard sets up WireGuard for you. It creates the server, the zone, the rules and the internet sharing, and a key for every device. When it finishes, it shows each device a QR code for the WireGuard app and a complete configuration file to download. Phones scan the code; laptops and PCs import the file.

What you need:

  • The free WireGuard app on each device: App Store, Google Play, or wireguard.com for Windows, macOS and Linux.
  • The address people connect to from outside: your internet address, or a name for it (see Network › DNS › Dynamic DNS if your address changes).
  • If another router sits in front of Korthveil, a port forward on it of UDP 51820 to Korthveil.

Not in FIPS mode. WireGuard uses algorithms that are not FIPS-approved. On a firewall in FIPS mode, use IPsec or IKEv2 remote access instead.

What the wizard sets up

Part What it does
A WireGuard server tunnel (wg0, or the next free name) Listens on UDP 51820 (or the next free port) on your internet zone, with its own key pair and tunnel addresses, IPv4 and IPv6. An existing enabled tunnel in the same zone is used instead.
A zone for VPN users (vpn) Your rules treat VPN users on their own.
Allow rules From vpn to each network you choose, and to the internet if you send all traffic through the firewall.
Internet sharing (NAT) Only for full tunnel: VPN users' internet traffic leaves from your internet address.
The firewall's DNS for devices (from 1.1.101) When the DNS resolver (or DNS forwarder) is on, each device's file says DNS = the tunnel's own addresses, and the resolver also answers the vpn zone, including the tunnel's devices. VPN users then get your DNS filtering and ad blocking too. A tunnel that already has DNS servers for devices keeps them.
One key per device Each device gets its own private key, its own tunnel addresses, and its own configuration.

Nothing is applied until you press Apply, and the change rolls back by itself unless you confirm it within five minutes.

Step 1: Choose WireGuard

Open System › Wizards and choose Remote-access VPN. WireGuard is chosen already: it is fast, and every platform has a free app.

Changes already waiting? If the wizard shows Changes are already waiting to be committed, something was left unfinished: an earlier run of a wizard that stopped at its review, another page, or another administrator. Press Review them to see them on the Commit page, or Discard them… if they are from an earlier run of this wizard. Running the wizard on top would add everything twice. (From 1.2.4. Leaving a wizard's review for another page of the console also puts the pending changes back by itself.)

Changes already waiting: review them, or discard them first
Changes already waiting: review them, or discard them first
Step 1: WireGuard, recommended
Step 1: WireGuard, recommended

Step 2: Where devices connect

  • Public name or address: what devices connect to from outside, for example vpn.example.com or your internet address. It is written into every device's configuration. If the firewall has a name under Network › DNS › Dynamic DNS, the wizard fills it in for you.
  • VPN users' zone: vpn. It is created if it does not exist. Names are compared ignoring case: if a zone VPN exists, vpn means that zone.

The wizard checks the public name before it changes anything (from 1.2.4). It refuses an address inside your network (such as 192.168.1.10) and a name that points only to one, because phones on mobile data and computers elsewhere can't reach it. The message names what to use instead, for example: home.example.com points to 192.168.1.11, an address inside your network: devices on the internet or on mobile data cannot reach it. Use your dynamic DNS name myhome.dynamic.example, or your internet address 203.0.113.7. Your firewall's own dynamic DNS names are always accepted.

An address inside the network is refused, with what to use instead
An address inside the network is refused, with what to use instead
Step 2: the public name and the VPN users' zone
Step 2: the public name and the VPN users' zone

The pictures use a zone named remote, because the test firewall already has a vpn zone with its own tunnel. On a firewall without one, keep vpn.

Step 3: The devices

Type one name per line: one per device, not per person, for example alice-laptop and bob-phone. Each device gets its own key, so a lost phone can be removed on its own while the others keep working.

Step 3: one line per device
Step 3: one line per device

Step 4: What they may reach

  • Networks they may reach: tick the internal networks VPN users may use, for example your office LAN.
  • They may open this firewall's console (from 1.3.9): the web console and SSH on the firewall's own addresses, its LAN address and the failover address, over the VPN. Tick it for administrators who manage the firewall away from home. Off: they reach your networks but the firewall refuses its console to them, because only management zones may open it (Network › Interfaces, zones & routes, the zone's Management).
  • Send all their internet traffic through the firewall (full tunnel): safer on public Wi-Fi, because their browsing leaves from your internet address, through your filters. Off (split tunnel): only your networks go through the VPN.
  • Their internet leaves through (full tunnel, from 1.2.4): choose a VPN group, for example your IPVanish or NordVPN tunnels or your own VPN, or Directly through your internet line. When the firewall has a VPN group, the wizard chooses it for you: the group with the most tunnels. Through a VPN, websites see the VPN provider's address, not yours. Your own networks are always reached directly, never through the provider. If every tunnel of the group is down, the group decides: with its kill switch on their internet stops; with it off, it goes out through your internet line. The review says which.

No VPN group yet? Set one up with System › Wizards › VPN provider with failover, then run this wizard again. The choice adds a policy route VPN users via (group), which you can see under Network › Routing & WAN › Policy routing.

Step 4: networks, and full tunnel
Step 4: networks, and full tunnel

Step 5: Review and apply

Review lists everything the wizard adds: the zone, the rules, the tunnel, the devices, the NAT, and which DNS the devices use. Press Apply, then Keep these settings. If nobody confirms within five minutes, the firewall goes back to the previous settings by itself.

Review: every change before it is applied
Review: every change before it is applied

Step 6: A QR code and a file for each device

After you keep the settings, the wizard shows every device's QR code and a download button for its configuration file (alice-laptop.conf, bob-phone.conf).

Each device: its QR code and its configuration file
Each device: its QR code and its configuration file
  • Phone or tablet: in the WireGuard app, tap +, then Scan from QR code, and scan the code from the screen. Name the tunnel and switch it on.
  • Windows or macOS: download the file, then in the WireGuard app choose Import tunnel(s) from file and pick it. Press Activate.
  • Linux: save the file as /etc/wireguard/wg0.conf and run wg-quick up wg0.

This is the only time each private key is shown. Korthveil keeps only the devices' public keys, so it can't show the code again. Scan or download every device now. If you miss one, re-key it later (see below).

Send a file to its owner safely, for example through a password manager or by hand: whoever has the file can connect as that device.

What is in the file

The QR code and the file hold the same complete configuration. An example, with fake keys. The QR codes in this guide's pictures are this example too, never a real device's:

# Korthveil WireGuard: example-phone on wg0 (EXAMPLE, not a real key)
[Interface]
PrivateKey = EXAMPLE0PRIVATE0KEY0not0a0real0key000000000=
Address = 10.250.0.2/32, fd12:3456:789a::2/128
DNS = 10.250.0.1, fd12:3456:789a::1

[Peer]
PublicKey = EXAMPLE0FIREWALL0PUBLIC0KEY0not0real0000000=
Endpoint = vpn.example.com:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
  • Address: the device's own tunnel addresses, IPv4 and IPv6.
  • DNS: the firewall itself, at the tunnel's addresses, so your DNS filtering and ad blocking protect VPN users wherever they are. The wizard sets it when the DNS resolver or forwarder is on (Network › DNS › DNS resolver). Without one, the line is left out and devices keep their own DNS. Turn the resolver on and re-key the devices to add it later.
  • Endpoint: the public name from Step 2 and the tunnel's port.
  • AllowedIPs: 0.0.0.0/0, ::/0 with full tunnel; with split tunnel, only the networks you chose in Step 4.

Later: add, re-key or remove a device

Open VPN › WireGuard and choose the tunnel in Tunnels (the wizard's is the one in the VPN users' zone). Under Remote devices, each device has one line, with its addresses, tunnel mode and DNS.

Remote devices: one line per device
Remote devices: one line per device
  • Add a device: Add device. It gets its own QR code and file, shown once, the same way.
  • A QR code again, or a lost or replaced device: the QR icon in the device's row (New QR code) gives it new keys and a new QR code. A QR code can't be shown twice, because the firewall never keeps a device's private key. The old configuration stops working once you commit.
  • Block a device for now: open it and untick Enabled. Remove it for good with the bin.
  • Where their internet leaves: on VPN › WireGuard, a server tunnel with devices has Their internet leaves through, the same choice as in the wizard. Change it there and save. VPN › OpenVPN (for each server), VPN › Remote access (IKEv2) and VPN › SSL VPN have it too, for their VPN users' zone.
The same choice on VPN › WireGuard
The same choice on VPN › WireGuard

The tunnel's status shows every device's last handshake and its traffic, so you can see who is connected.

If a device does not connect

  • No handshake at all: the device can't reach the firewall. Check the public name, and the port forward of UDP 51820 if another router sits in front of Korthveil. Mobile data reaches it from outside; your own Wi-Fi may not, unless your router supports hairpin NAT.
  • Handshake, but no internet: with full tunnel, check that Send all their internet traffic through the firewall was on, so the wizard added the NAT and the internet rule.
  • Handshake, but an internal network is unreachable: tick that network in Step 4, or add an allow rule from vpn to it.
  • Other devices work, but not the firewall itself (its LAN address or the failover address, for example 192.168.1.4 or .1): the VPN zone isn't a management zone. Run the wizard again and tick They may open this firewall's console, or turn on Management for the zone under Network › Interfaces, zones & routes.
  • Monitoring › Traffic log shows each allowed and blocked connection from the vpn zone, with the rule that decided it.

For a hands-on example with exact addresses, see Connect your phone and laptop with WireGuard (QR code). It also sends VPN users through a VPN provider.

Download as PDF All guides