Connecting a PC or a phone with WireGuard

Laura White, who looks after IT at John Smith Ltd, must reach the headquarters NAS (nas.johnsmith.test, 192.168.10.20) and the ERP (192.168.10.41) from home and when travelling, with her Windows…

Situation

Laura White, who looks after IT at John Smith Ltd, must reach the headquarters NAS (nas.johnsmith.test, 192.168.10.20) and the ERP (192.168.10.41) from home and when travelling, with her Windows laptop and her phone. Headquarters has the office LAN 192.168.10.0/24, the appliance 192.168.10.1 and the fibre’s public address 203.0.113.10; the tunnel to the branch (wg0, see Connecting two Argos sites with WireGuard) is already there.

Argos’s WireGuard VPN connects sites. A single device connects the same way, as “the other side” of a profile that has one address only: one profile per device, in VPN → VPN WireGuard. For a device the profile has three particulars:

  • the Endpoint stays empty: the device has no fixed address and always calls itself, from any network;
  • there are no Remote networks: behind the device there is no network, just its address in the tunnel;
  • the device’s private key is generated by the WireGuard app on the device, and never leaves it. Argos only gets its public key.

Each profile has a UDP port of its own (51821, 51822…) and a small tunnel network of its own (10.100.1.0/30, 10.100.2.0/30…). The devices’ tunnels go into a zone of their own, devices, which reaches the LAN and the appliance’s resolver and nothing else.

This scenario is for a few devices: the laptop of whoever looks after IT, the partner technician’s, a phone. Remote access for the staff, with an account per person and the RADIUS server checking the logins, is EDON Atlas’s “VPN Roadwarrior” (see EDON Atlas).

What you need

  • Access to the appliance’s console.
  • On the device, the official WireGuard app, free of charge:
    • Windows 10 and 11: from wireguard.com/install (“Download Windows Installer”), installed by an administrator of the PC;
    • macOS: “WireGuard” from the Mac App Store;
    • Linux: the distribution’s wireguard-tools package, or NetworkManager, which handles WireGuard by itself;
    • Android: “WireGuard” from Google Play (developer WireGuard Development Team) or from F-Droid;
    • iPhone and iPad: “WireGuard” from the App Store.
  • Argos reachable from the internet on the profile’s UDP port: directly on its WAN address, or through the router in front of it, with the port forwarded to Argos.
  • DNS protection on, if you want the headquarters names (nas.johnsmith.test) on the device too.
  • A secure channel to bring the configuration Argos exports to the device: it holds the pre-shared key, which must be treated like a password.

Steps

On Argos: the laptop’s profile

  1. Open VPN → VPN WireGuard and press “Add VPN” (the + in the list’s bar). “VPN WireGuard / New VPN” opens.
  2. Fill in:
    • “Description”: Laura White's laptop;
    • “Listen port”: leave it empty. On save the console takes the first free UDP port from 51820 up: here 51821, because 51820 belongs to the branch tunnel;
    • “Endpoint”: leave it empty;
    • “Endpoint public key”: leave it empty for now: the app on the laptop generates it;
    • “Pre-shared key”: press the icon at the right of the field (“Generate a pre-shared key”);
    • “Remote networks”: none;
    • “Enabled”: on;
    • “On demand”: on. The laptop connects only when it needs to: this way System status → Status does not report the VPN as not connected while it is off or at the office.
  3. Press “Create VPN”. “VPN applied” appears. Argos chose the interface (wg1), the tunnel address (10.100.1.1/30: the laptop gets 10.100.1.2), the listen port (51821) and its own key pair.
The laptop's profile, waiting for its keyThe laptop's profile, waiting for its key
The laptop's profile, waiting for its key

In the list the row reads “Waiting for the key”. Under “Listen port” the detail says: “No Endpoint: the firewall opens UDP port 51821 to any address (only the holder of the Endpoint’s key gets in); it holds once the firewall is applied.” Opening the port to everyone is what a device needs when it connects now from a customer’s office, now over 4G: WireGuard does not answer anyone without the right key.

On Argos: the laptop’s configuration

  1. With the profile selected, press “Endpoint configuration” (the icon in the detail’s bar). “Endpoint configuration — wg1” opens with the text for the laptop:

    [Interface]
    Address = 10.100.1.2/30
    PrivateKey = <peer-private-key>
    
    [Peer]
    PublicKey = …
    PresharedKey = …
    Endpoint = 203.0.113.10:51821
    AllowedIPs = 192.168.10.0/24, 10.100.1.0/30
    PersistentKeepalive = 25
    • Address is the laptop’s address in the tunnel;
    • PrivateKey is a placeholder: the private key is put there by the laptop’s WireGuard app, which generates it. That is why the window says “Values in angle brackets are not known here: fill them in on the remote site.”;
    • Endpoint is where the laptop finds Argos: the public address headquarters goes out to the internet with (or the console’s Let’s Encrypt domain, if there is one), with the profile’s port;
    • AllowedIPs are the networks the laptop sends into the tunnel: the lan zone’s networks and the tunnel network. The rest of its traffic, the internet included, leaves through its own connection;
    • PersistentKeepalive = 25 keeps the tunnel open behind the NAT of a home router or a mobile operator too.
  2. Press “Copy” and bring the text to the laptop over a secure channel.

The configuration for the laptopThe configuration for the laptop
The configuration for the laptop

To use the headquarters names, on the device you will add a line the exported text does not have: DNS = 192.168.10.1, the appliance itself, which answers through the tunnel (the devices zone opens port 53 to it in step 13).

On the device

Each app generates its own key pair and shows the public key: it is the value to bring to Argos (step 10). Public keys are not secret.

Windows

  1. Open WireGuard. Press the arrow next to “Add Tunnel” and choose “Add empty tunnel…”. “Create new tunnel” opens: at the top “Public key” with the key just generated, below it a text that starts with [Interface] and a PrivateKey line already filled in.
  2. In “Name” type argos-hq. In the text leave [Interface] and the PrivateKey line as they are, and paste the exported text below them starting from Address: the export’s [Interface] and PrivateKey = <peer-private-key> lines are not needed. Under Address add DNS = 192.168.10.1.
  3. Copy the “Public key” value, press “Save”, then “Activate”.

macOS

Open WireGuard and choose “Add Empty Tunnel…” (from the + at the bottom of the tunnels window, or from the menu of the WireGuard icon in the menu bar). The window is the same as on Windows: “Name”, “Public key” and the text with the PrivateKey already generated. Complete the text as in step 7, copy the public key and save; on the first save macOS asks to allow adding a VPN configuration. Activate the tunnel from the window or from the menu bar.

Linux

With NetworkManager (the GNOME, KDE and similar desktops):

wg genkey > argos-hq.key
wg pubkey < argos-hq.key

The second command prints the public key. Save the exported text in a file argos-hq.conf, put the content of argos-hq.key in place of <peer-private-key>, add DNS = 192.168.10.1 under Address, then:

nmcli connection import type wireguard file argos-hq.conf

The argos-hq connection appears among the system’s VPNs; delete the two files, which are no longer needed (NetworkManager now keeps the private key).

Without NetworkManager, with wg-quick (package wireguard-tools):

sudo sh -c 'umask 077; wg genkey > /etc/wireguard/argos-hq.key'
sudo wg pubkey < /etc/wireguard/argos-hq.key

Write the exported text in /etc/wireguard/argos-hq.conf (mode 600), with the content of argos-hq.key in place of <peer-private-key> and the line DNS = 192.168.10.1. Bring the tunnel up with sudo wg-quick up argos-hq, and at every boot with sudo systemctl enable wg-quick@argos-hq. The DNS line needs the resolvconf command: if the system lacks it, install the openresolv package (or drop the line and use addresses).

Android

Open WireGuard, press + and choose “Create from scratch”. Fill in:

  • “Name”: argos-hq;
  • “Private key”: tap the icon at the right of the field (“Generate new private key”). Below it the “Public key” appears: it is the one to bring to Argos;
  • “Addresses”: the export’s Address;
  • “DNS servers”: 192.168.10.1.

Then press “Add peer” and fill in the values of the [Peer] section: “Public key” (the PublicKey), “Pre-shared key” (the PresharedKey), “Persistent keepalive” 25, “Endpoint” and “Allowed IPs”. Save with the icon at the top and switch the tunnel on; on the first connection Android asks for permission to create a VPN.

iPhone and iPad

Open WireGuard, tap “Add a tunnel” (or the +) and choose “Create from scratch”. Fill in “Name”, tap “Generate keypair” (the “Public key” to bring to Argos appears), then “Addresses” and “DNS servers” as on Android. With “Add peer” fill in “Public key”, “Preshared key”, “Endpoint”, “Allowed IPs” and “Persistent keepalive” 25. Tap “Save”; iOS asks to allow adding a VPN configuration. Switch the tunnel on from the list.

Tip On a phone the keys are long to type: copy them from the exported text, which you can open on the phone from a secure channel (an encrypted note, the password manager). Do not send it in clear by e-mail or in a chat.

On Argos: the device’s key

  1. Get the public key the app showed.
  2. In VPN → VPN WireGuard open wg1, paste the key into “Endpoint public key” and press “Save VPN”. The row loses “Waiting for the key”.

On Argos: the devices zone

The zone is created once; the devices that follow only add their interface to it.

  1. Open Zones and rules → Zones and press “Add zone”. “Zones / New zone” opens.
  2. Fill in:
    • “Name”: devices;
    • “Description”: Laptops and phones over VPN;
    • “Inbound policy”: “Drop” (the devices do not reach the appliance, except the DNS below: neither the console nor SSH);
    • “Forward policy”: “Drop”;
    • “Masquerade (SNAT)”: off: the headquarters servers see the device’s address in the tunnel (10.100.1.2), and the logs say who it was;
    • “Answer ping (ICMP)”: on, you need it for the checks;
    • “Forwarding matrix”: next to “LAN” choose “Accept”; leave “Zone default” for the others, WAN included;
    • “Interfaces”: switch on wg1.
  3. In the “Inbound services” section press “Add service” and add “Protocol” UDP, “Ports” 53, “Comment” Device DNS; then a second identical service with “Protocol” TCP.
  4. Press “Create zone”.
The “devices” zone with the laptop's and the phone's tunnelsThe “devices” zone with the laptop's and the phone's tunnels
The “devices” zone with the laptop's and the phone's tunnels

If you want a device to reach only some servers, instead of “Accept” in the matrix leave “Zone default” and add in “Forward rules”, with “Add rule”, one rule per server: for example “Destination zone” LAN, “Action” “Accept”, “Protocol” TCP, “Ports” 445, “Destination” 192.168.10.20 for the NAS shares.

On Argos: apply

  1. In the header open the firewall button (“Unapplied changes”) and choose “Apply”.
  2. In the “Keep the new ruleset?” window press “Confirm” within 60 seconds.

From now on port 51821 is open and the laptop connects. If headquarters has a router in front of Argos, forward UDP port 51821 to the appliance there.

The phone, and every other device

Repeat the steps for each device, with a profile of its own: for the phone “Description” Laura White's phone. Argos gives it wg2, 10.100.2.1/30 (the phone is 10.100.2.2) and port 51822. In the devices zone switch on wg2 too (step 12) and save the zone with “Save zone”; then apply and confirm. If there is a router in front of Argos, forward 51822 too.

The headquarters profiles: the branch, the laptop and the phoneThe headquarters profiles: the branch, the laptop and the phone
The headquarters profiles: the branch, the laptop and the phone

One profile per device, not one per person: if the laptop is lost, switch off or delete its profile and the phone keeps working.

For the technician Each device is a wg-quick@wgN profile like a site’s: AllowedIPs on the Argos side is the tunnel network only (10.100.1.0/30), because the profile has no remote networks; wg-quick installs no other route. The firewall rule is in input, ahead of the zones: udp dport 51821 counter accept comment "vpn wg1: peers from any address". The decrypted traffic comes in from wg1 and follows the devices zone (chains zone_devices_in and zone_devices_fwd). The resolver listens with interface-automatic: it answers from the address the device asked (192.168.10.1), even though the answer leaves through the tunnel, whose address is another.

Variant: all of the device’s traffic goes through headquarters

Sometimes the device must go out to the internet with the headquarters address (a service that accepts only that one) or with Argos’s protections.

  1. On the device, in AllowedIPs (on Android and iPhone “Allowed IPs”) put 0.0.0.0/0 in place of the headquarters networks. On Windows the option “Block untunneled traffic (kill-switch)” appears: leave it on.
  2. On Argos, in the devices zone, next to “WAN” in the “Forwarding matrix” choose “Accept”; save, apply and confirm. The wan zone’s masquerade, on by default, sends the traffic out with the headquarters address.

Argos routes IPv4 only: if the device has IPv6 too, add ::/0 to the allowed IPs, so that its IPv6 traffic does not leave through its own connection; the sites answer it over IPv4.

Check

  1. In System status → Status, card “Gateways and tunnels”, under “VPN tunnels” there are wg1 and wg2 with the green dot, “Handshake” and the time elapsed. The app on the device also shows the latest handshake and the bytes received and sent.
  2. From the laptop connected outside headquarters (for example through the phone’s hotspot) run ping 192.168.10.1, then open \\nas.johnsmith.test: the name resolves and the NAS answers.
  3. If something is dropped, in Events and diagnostics → Firewall filter by devices: the lines zone-devices-in, zone-devices-fwd or zone-devices-to-lan tell you which rule stopped the traffic.

When a device is no longer needed

If a device is lost, or the person leaves the company, open its profile in VPN → VPN WireGuard and press “Delete VPN”: to the question “Delete VPN wg1? The tunnel goes down and its config is removed.” confirm. The tunnel goes down at once, the key left on the device opens nothing any more and the interface leaves the devices zone. Then apply the firewall, which closes the profile’s port. To suspend it instead, switch “Enabled” off and press “Save VPN”.

What about OpenVPN or IPsec?

For a single device use WireGuard.

  • IPsec no: the IPsec clients built into Windows, macOS, iPhone and Android ask the appliance for an address to use in the tunnel (and usually for DNS servers), and Argos’s IPsec VPN assigns none: it connects sites with fixed networks (see IPsec tunnel with another vendor’s firewall).
  • OpenVPN does not suit it: an Argos OpenVPN profile also connects one other side only, but a listening profile wants at least one remote network, which a device does not have, and the device’s certificate would have to be made by hand.

If something goes wrong

The device does not handshake. Check, in order:

  • the firewall is applied and confirmed: if the button in the header says “Unapplied changes”, the port is not open yet;
  • the Endpoint port on the device is the “Listen port” of its profile (51821 for the laptop, 51822 for the phone);
  • if Argos sits behind a router, the port is forwarded to the appliance;
  • Argos’s “Endpoint public key” holds the device’s public key, and the device’s PublicKey holds Argos’s, not the other way round;
  • the pre-shared key is the same on both sides (if you generated it again, bring the new one to the device);
  • the network the device connects from does not block UDP ports (some guest networks do: try through the phone’s hotspot).

The export contains <argos-public-address>. Argos does not know the address headquarters goes out to the internet with: write the public address, or a name that resolves to it, in place of the placeholder.

There is a handshake but the traffic does not pass.

  • wg1 is not in the devices zone: unzoned-fwd lines show up in the firewall log. Add it to the zone.
  • The zone’s matrix does not open the LAN, or a forward rule limits it: zone-devices-fwd or zone-devices-to-lan lines.
  • The network the device connects from is the same as headquarters’ (a home router with 192.168.10.0/24): the device looks for the NAS on the local network and not in the tunnel. From that network headquarters cannot be reached; connect from another one (the phone’s hotspot).
  • The destination server refuses traffic from another network (the Windows firewall often does so with ping and shares).

Names do not resolve, addresses do. The device lacks the line DNS = 192.168.10.1 (on Android and iPhone “DNS servers”), the devices zone lacks the UDP and TCP 53 services, or DNS protection is off. On Linux with wg-quick, without resolvconf the tunnel does not come up at all while the DNS line is there.

The tunnel drops after a few minutes without traffic. The PersistentKeepalive = 25 line is missing (on Android and iPhone “Persistent keepalive”): without it the router or the mobile operator forgets the translation and Argos can no longer reach the device.

LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer