Connect two machines with fv run
Make keys, write two config files and start fv run on two Linux machines, then check the tunnel with fv show and a ping over IPv4 and IPv6.
Two Linux machines get a private tunnel between them, over IPv4 and IPv6, with no account. Machine A has a public address and listens. Machine B may sit behind NAT and dials A. B asks for a post-quantum key exchange and A answers it: one ML-KEM-1024 key exchange, whose secret goes into WireGuard's pre-shared-key slot.
Before you start
- Two x86-64 Linux machines with the
forestvpn-quantumpackage installed, which putsfvat/usr/bin/fv. The command-line download page has the install steps. - From the binary instead of the package: put
fvat/usr/bin/fv. - Root on both.
fv runneeds/dev/net/tunand runsip. - A reachable address for A, here
203.0.113.10as an example. Use A's own address everywhere you see it. - UDP port 51820 open on A, in your own firewall. If you use
ufw, that issudo ufw allow 51820/udp. - The package's install hint names two setups. The first,
systemctl enable --now fv@<iface>, is yours: it starts a tunnel from your own config (see Start an fv tunnel at boot). Ignore the second, which enablesforestvpn-quantum-firewallandforestvpn-quantum@fvpn0: that is the exit-server setup, and it replaces this machine's firewall. An older package names only the exit-server setup. - About ten minutes.
The names and addresses below are examples: the tunnel is fvq0 and the tunnel addresses are 10.66.0.1, 10.66.0.2, fd66::1 and fd66::2. The name fvq0 fits Linux's 15-character limit, and it does not start with fvpn, the prefix the package's exit-server firewall treats as a client tunnel. That firewall should not run on these machines (see Start an fv tunnel at boot).
Steps
-
On each machine, make a private key and print the public key. The private key stays on its own machine.
Writes the private key to a file only root can read, and prints the public key to share
sudo sh -c 'install -d -m 0750 /etc/forestvpn; umask 077; fv genkey > /etc/forestvpn/key; fv pubkey < /etc/forestvpn/key' -
On one machine, make a pre-shared key and copy it to the other. It is optional, but if you use it, both ends need the same one.
Prints a random 32-byte key in base64
fv genpskIf
fv genpskprintsunknown command, yourfvis older: upgrade it, or make the key withhead -c 32 /dev/urandom | base64, which prints the same kind of key. -
On A, write
/etc/forestvpn/fvq0.conf. Put A's private key (the content of/etc/forestvpn/key), B's public key and the pre-shared key where the placeholders are. Keep the file readable by root only.Machine A: listens on 51820 and answers the post-quantum ML-KEM-1024 exchange
[Interface] PrivateKey = <A private key> ListenPort = 51820 Address = 10.66.0.1/24, fd66::1/64 MTU = 1416 PostQuantum = respond [Peer] # machine B PublicKey = <B public key> PresharedKey = <shared PSK> AllowedIPs = 10.66.0.2/32, fd66::2/128 -
On B, write
/etc/forestvpn/fvq0.confthe same way, with B's private key, A's public key and the same pre-shared key.Endpointis A's address and port.Machine B: dials A and requires the post-quantum ML-KEM-1024 exchange
[Interface] PrivateKey = <B private key> Address = 10.66.0.2/24, fd66::2/64 MTU = 1416 PostQuantum = require [Peer] PublicKey = <A public key> PresharedKey = <shared PSK> Endpoint = 203.0.113.10:51820 AllowedIPs = 10.66.0.1/32, fd66::1/128 PersistentKeepalive = 25 -
Start
fvon A, then on B. Each command stays in the foreground, so use a terminal each, or a boot unit later.Starts the tunnel; stop it with Ctrl+C
sudo fv run --iface fvq0 --config /etc/forestvpn/fvq0.conf
Check it worked
-
On either machine, in another terminal, read the tunnel.
Prints the interface and the peer, with a latest handshake and the ML-KEM-1024 state, shown as post-quantum
sudo fv show fvq0The peer block should show a
latest handshakeand the linepost-quantum: on (resets 0). Right after the start there may be no handshake yet: B sends its first one with its first packet or its first keepalive, up to 25 seconds after it starts. Until then there is nolatest handshake, B readspendingand A readsoff. Wait half a minute and runsudo fv show fvq0again.fv showalso prints apq_pskline for the interface. It never prints a private or pre-shared key: they read(hidden)and(set). -
From B, ping A's tunnel address over IPv4 and over IPv6.
Both should answer
ping -c 3 10.66.0.1 ping -c 3 fd66::1 -
From A, ping B the same way, with
10.66.0.2andfd66::2.
If B shows post-quantum: pending or unsupported, and nothing answers, the usual cause is a mismatch: both ends require, or A not respond. require is strict: user traffic only travels once the exchange has finished. See what to check.
Two things about the pair:
- Both sides
requirenever connects, and bothrespondconnects without the ML-KEM-1024 exchange. One end must offer (require) and the other answer (respond). - Changing
PostQuantumneeds a restart. Edit the file and stop and startfv run.fv set <iface> pq_psk=...only reaches peers created after it.
Optional, with fv on both ends only: HeaderMask = on in B's [Peer] block masks the outer WireGuard header, and ObfuscationTrailer = v2 in both selects the v2 trailer. They are described in the config reference. Reaching a stock WireGuard peer is a different setup: see using fv with stock WireGuard.