Skip to content

Reach fxbot with WireGuard

Copy all docs

A WireGuard tunnel from your phone to your home network works where web pairing can’t connect directly, run by you, with no account anywhere. It needs one UDP port open at home, so it doesn’t help when your provider’s NAT is in front of your router (carrier-grade NAT). There, use Tailscale or a TURN server.

  • On the router, if it has WireGuard, as OpenWrt, OPNsense, pfSense, UniFi, and many others do. Follow its own guide, then skip to Open fxbot through it.
  • On fxbot’s machine, with UDP 51820 forwarded to it on the router. The steps below are for Debian or Ubuntu.
  1. Install it, and make the machine’s keys:

    Terminal window
    sudo apt install wireguard qrencode
    wg genkey | sudo tee /etc/wireguard/server.key | wg pubkey | sudo tee /etc/wireguard/server.pub
  2. Make a key pair for the phone:

    Terminal window
    wg genkey | tee phone.key | wg pubkey > phone.pub
  3. Write /etc/wireguard/wg0.conf:

    [Interface]
    Address = 10.88.0.1/24
    ListenPort = 51820
    PrivateKey = <the contents of /etc/wireguard/server.key>
    [Peer]
    # The phone: it reaches this machine only.
    PublicKey = <the contents of phone.pub>
    AllowedIPs = 10.88.0.2/32
  4. Start it, and open the port:

    Terminal window
    sudo systemctl enable --now wg-quick@wg0
    sudo ufw allow 51820/udp

    On the router, forward UDP 51820 to this machine, as Forward or map a port shows.

  5. Make the phone’s config, phone.conf:

    [Interface]
    Address = 10.88.0.2/32
    PrivateKey = <the contents of phone.key>
    [Peer]
    PublicKey = <the contents of /etc/wireguard/server.pub>
    Endpoint = <your home's public address or name>:51820
    # Only fxbot's machine goes through the tunnel; everything else goes as usual.
    AllowedIPs = 10.88.0.1/32
    PersistentKeepalive = 25
  6. Give it to the phone. Install the WireGuard app, tap +, then Scan from QR code, and scan:

    Terminal window
    qrencode -t ansiutf8 < phone.conf

    Then delete phone.key and phone.conf. Each phone gets its own key pair and [Peer], at the next address.

fxbot listens on the machine’s loopback only, so the tunnel alone doesn’t reach it. Either:

  • Use web pairing through the tunnel. With the tunnel on, the phone and fxbot can likely connect over it, since the tunnel’s address is one of fxbot’s candidates. Open web.fxbot.sh as usual.
  • Or put a proxy on the tunnel’s address, such as Caddy listening on 10.88.0.1 and passing to 127.0.0.1:8787, as Reach it describes. A phone installs the app only over HTTPS.