Get started with the CLI
flextunnel command, give a server its identity and a client its key, start both, and reach what is behind the server through the client's local SOCKS5 proxy. Then the throwaway --quick tunnel, the status pages, the control panel, and keeping a client running under systemd. Every flag and setting is in Configuration and routing.On this page
All flextunnel guides
Install
One binary is both the server and the client. By default, the install scripts download the latest stable release and check its checksum.
curl -sSL https://flexaccessdev.github.io/flextunnel/install.sh | bashirm https://flexaccessdev.github.io/flextunnel/install.ps1 | iexOn Linux and macOS it goes to ~/.local/bin, with no root; the script says what to add to your PATH if needed. On Windows it installs to C:\Program Files\flextunnel, which is why the installer needs an Administrator PowerShell; running flextunnel afterwards does not. Every binary is on the GitHub Releases page.
Install a specific release or download only
To pin a release, pass its tag in place of vX.Y.Z:
curl -sSL https://flexaccessdev.github.io/flextunnel/install.sh | bash -s -- vX.Y.Z$install = [scriptblock]::Create((irm https://flexaccessdev.github.io/flextunnel/install.ps1))
& $install vX.Y.ZIn place of the tag, --prerelease (-PreRelease in PowerShell) installs the latest prerelease. --download-only (-DownloadOnly), alone or with a tag, saves the binary to the current directory without installing it.
A container image is published at ghcr.io/flexaccessdev/flextunnel, with flextunnel as its entrypoint:
docker run --rm -it -v "$PWD:/work" -w /work \
ghcr.io/flexaccessdev/flextunnel server start -c server.tomlThe same tunnel also comes as a desktop app and as apps for iOS and Android.
A client and a server connect when they speak the same protocol version, even when their release numbers differ. To see which protocol each end speaks, run flextunnel --version on the server and on any CLI client. It prints the release and the protocol, as in flextunnel X.Y.Z (protocol N). The desktop app shows the same in its footer, and the iOS and Android apps show the number after the core version, as in core X.Y.Z · protocol N. Older releases may omit the number. In that case, check PROTOCOL_VERSION in crates/flextunnel-core/src/proxy/signaling.rs at the reported core release tag. A release that changes the protocol needs the server and every client upgraded together.
Make the keys
The recording runs the next four steps on two Linux hosts: the server on the left, the client on the right.
Loading the recording…
A server has an identity key. Its public half, the endpoint ID, is what clients dial, so a server needs no public address and no open port.
flextunnel generate-iroh-key -o server.key # prints the server's endpoint ID
flextunnel show-iroh-id --secret-file server.key # prints it again laterEach client has its own auth key, made with the separate flexaccess-keys command. Install it the same way:
curl -sSL https://flexaccessdev.github.io/flexaccess-keys/install.sh | bashirm https://flexaccessdev.github.io/flexaccess-keys/install.ps1 | iexThen, on each client machine, make its key and print the public entry the server will need:
flexaccess-keys generate-auth-key "alice laptop" -o client.key
flexaccess-keys show-auth-key --private-key-file client.key
# → ed25519-pub:… alice laptopKeep server.key and every client.key private. Give the server's endpoint ID to the clients, and put each client's ed25519-pub:… entry in the server's authorized keys file, one per line:
ed25519-pub:XXXXXXXX alice laptop
ed25519-pub:YYYYYYYY build serverStart a server
A server needs its identity and the clients it authorizes. That alone lets clients reach the machine it runs on: its own localhost, on any port. The two routed lists are optional and say what else clients may reach through it.
secret_file = "./server.key"
authorized_keys_file = "./authorized_keys"
# Optional: what else clients may reach through this server.
routed_domains = ["*.corp.example"]
routed_cidrs = ["10.0.0.0/8"]flextunnel server start -c server.tomlRestart the server after editing its authorized keys file so it loads the updated list.
No root is needed. On startup it logs flextunnel server Node ID: <ENDPOINT_ID>: that is the ID to give clients. To let clients reach everything the server can, use routed_domains = ["*"] and routed_cidrs = ["0.0.0.0/0", "::/0"]; see Routing.
Start a client
A client names each server it reaches as a destination. Add more [[destinations]] tables for more servers.
socks_port = 1080 # SOCKS5 on 127.0.0.1:1080, loopback only
auth_key_file = "./client.key"
[[destinations]]
name = "office"
server_node_id = "SERVER_ENDPOINT_ID"
# Optional: send more than the server machine itself through this server.
# The server must allow these too (its own routed_domains / routed_cidrs).
routed_domains = ["*.corp.example"]
routed_cidrs = ["10.0.0.0/8"]name is one DNS label of your choosing (letters, digits and hyphens). office.localhost.flextunnel.internal:<port> then reaches that port on the server machine itself.
flextunnel client start -c client.tomlStarting the client connects nothing: it connects to a server on first use and disconnects after five minutes unused (Connection lifecycle).
Use the tunnel
Point any SOCKS5 client at 127.0.0.1:1080. Use socks5h://, so hostnames reach flextunnel as names: that is what routes them, and a routed name is then resolved by the server.
# A destination's loopback name is the server machine: here, its port 8000.
curl -x socks5h://127.0.0.1:1080 http://office.localhost.flextunnel.internal:8000/
# A routed name: resolved and connected by that server.
curl -x socks5h://127.0.0.1:1080 https://wiki.corp.example/
# On no destination's list: connected directly from this machine.
curl -x socks5h://127.0.0.1:1080 https://example.comFor ssh no proxy port is needed: flextunnel client nc carries the connection through the running client.
ssh -o ProxyCommand='flextunnel client nc -c client.toml %h %p' user@office.localhost.flextunnel.internalRecipes for git, kubectl, browsers and other apps are in Use the proxy from your apps.
A quick throwaway tunnel
For a "route everything through this box for a few minutes" session, --quick skips all of the above: no key files and no config. Each side enters the other side's endpoint ID, and the server allows that one client only.
Loading the recording…
On the client, run
flextunnel client start --quick. It prints this client's endpoint ID and waits for the server's.On the server, run
flextunnel server start --quick. It asks for the client's endpoint ID and prints its own.Enter the server's ID at the client's prompt, then a SOCKS5 and an HTTP proxy port; leave one blank to keep that proxy off. The client connects and shows the live control panel in that terminal.
Both sides need an interactive terminal, and either can start first. The quick server routes everything and exits if the client does not connect within five minutes. The client's one destination is named quick, so quick.localhost.flextunnel.internal:<port> is the server's own loopback. Quitting the panel (q) disconnects and exits.
Status pages
flextunnel.internal is answered by the client itself, through either proxy listener, without connecting to anything. Open http://flextunnel.internal/ in a browser that uses the proxy, or fetch it from a script:
# plain text
curl -sS -x socks5h://127.0.0.1:1080 http://flextunnel.internal/status.txt
# JSON
curl -sS -x socks5h://127.0.0.1:1080 http://flextunnel.internal/status.jsonIt shows what each destination is doing (idle, connecting, connected, retrying) and the whole routing table, most specific rule first. A destination's rules show as unchecked until its first use, when the client first reads its server's lists.
Every status page starts with the release and the protocol it speaks, as flextunnel --version prints them: flextunnel X.Y.Z (protocol N) on the page, version and protocol lines in status.txt, and version and protocol fields in status.json.
Each server's own page, with its routed lists and host aliases, is under /servers/<name>/, with the same status.txt and status.json variants. Fetching it connects to that server.
curl -sS -x socks5h://127.0.0.1:1080 http://flextunnel.internal/servers/office/status.jsonOther *.flextunnel.internal names are reserved and answer with an HTTP 404. The JSON fields are listed in docs/status-json.md.
The control panel
flextunnel client control # the client from ~/.config/flextunnel/client.toml
flextunnel client control -c work.toml # the client started from a specific config
flextunnel client control -n work # or by the client's nameclient control attaches a read-only terminal panel to a running client. It lists the destinations with their live state, the selected one's details, and the port forwards from the config.
| Key | Does |
|---|---|
| ↑ ↓ (or k j) | Select a destination. |
| p | Show the selected destination's connection paths (direct or relay); Esc closes. |
| q (or Esc) | Detach. The client keeps running. |
Looking never connects anything. To change destinations or forwards, edit the config and restart the client.
Run it as a service
One client reaches every server listed as a destination in its config, so a single systemd user unit is the usual setup, however many servers you have.
Write the client config at
~/.config/flextunnel/client.toml, with a[[destinations]]table per server (see the client config reference).Save the unit, adjusting the path to
flextunnelif yours differs:~/.config/systemd/user/flextunnel-client.service[Unit] Description=flextunnel client [Service] ExecStart=%h/.local/bin/flextunnel client start -c %h/.config/flextunnel/client.toml Restart=on-failure RestartSec=5 [Install] WantedBy=default.targetEnable and start it, and let it start at boot and keep running after you log out:
systemctl --user daemon-reload systemctl --user enable --now flextunnel-client loginctl enable-linger "$USER"
An unreachable server or a rejected key does not stop the client, so a restart loop means a config, key file or port problem: read the journal. A destination that never connects although its server runs may be on another protocol: compare flextunnel --version on both ends (see Install). For a server's state, use the control panel or the status page. After editing the config, restart the unit:
systemctl --user restart flextunnel-client
journalctl --user -u flextunnel-client -f # follow its logMore than one client
A second client is only needed for a second set of local ports. Give each config its own name and ports, and use a template unit, one config per instance:
[Unit]
Description=flextunnel client (%i)
[Service]
ExecStart=%h/.local/bin/flextunnel client start -c %h/.config/flextunnel/%i.toml
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.targetsystemctl --user enable --now flextunnel-client@work flextunnel-client@home
flextunnel client control -n work