Command line

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.

Updated December 5, 2026

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-quantum package installed, which puts fv at /usr/bin/fv. The command-line download page has the install steps.
  • From the binary instead of the package: put fv at /usr/bin/fv.
  • Root on both. fv run needs /dev/net/tun and runs ip.
  • A reachable address for A, here 203.0.113.10 as 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 is sudo 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 enables forestvpn-quantum-firewall and forestvpn-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

  1. 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'
  2. 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 genpsk

    If fv genpsk prints unknown command, your fv is older: upgrade it, or make the key with head -c 32 /dev/urandom | base64, which prints the same kind of key.

  3. 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
  4. On B, write /etc/forestvpn/fvq0.conf the same way, with B's private key, A's public key and the same pre-shared key. Endpoint is 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
  5. Start fv on 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

  1. 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 fvq0

    The peer block should show a latest handshake and the line post-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 no latest handshake, B reads pending and A reads off. Wait half a minute and run sudo fv show fvq0 again. fv show also prints a pq_psk line for the interface. It never prints a private or pre-shared key: they read (hidden) and (set).

  2. 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
  3. From A, ping B the same way, with 10.66.0.2 and fd66::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 require never connects, and both respond connects without the ML-KEM-1024 exchange. One end must offer (require) and the other answer (respond).
  • Changing PostQuantum needs a restart. Edit the file and stop and start fv 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.

Back to Help

Back to top

Ask us anything