Skip to content

Tunnels over Tailscale

A saved tunnel normally reaches your server through the Reoclo gateway and the server’s runner. If the server and your machine are on the same Tailscale tailnet, the tunnel can dial the server directly instead. You can also publish a tunnel to the other devices on your tailnet.

This guide covers both. The command reference for every option is in reoclo tunnel.

  • A saved-tunnel setup that works over the relay. See reoclo tunnel.
  • Tailscale on your machine, signed in and running. The daemon runs tailscale status --json and treats the node as running only when its state is Running.
  • The server on the same tailnet, with the service listening on an address the tailnet can reach.

The daemon looks for the tailscale command on your PATH, then at /Applications/Tailscale.app/Contents/MacOS/Tailscale. To point it somewhere else, set REOCLO_TAILSCALE_PATH to the file before the daemon starts. When that variable is set, the daemon looks there only.

reoclo tunnel daemon status shows what the daemon sees:

tailscale_installed true
tailscale_running true
tailscale_https_certificates true
  1. Check the service’s bind address. The service must listen on 0.0.0.0, :: or the server’s tailnet address. A service that listens only on 127.0.0.1 on the server cannot be reached this way. reoclo servers ports lists each listening port with its address:

    Terminal window
    reoclo servers ports prod-1
  2. Save the tunnel with --via tailscale.

    Terminal window
    reoclo tunnel add prod-db --server prod-1 --target 5432 --via tailscale

    If the port scan shows that the port listens only on loopback, add prints a warning and still saves the tunnel. A port the scan does not list is allowed, because the scan may be out of date.

  3. Check the path.

    $ reoclo tunnel status prod-db
    NAME SERVER KIND LOCAL TARGET STATE PATH SHARED DETAIL
    prod-db prod-1 tcp 127.0.0.1:15432 prod-1:127.0.0.1:5432 ready tailscale

    With -o json, the peer field shows which tailnet peer the daemon matched and whether it is online.

The tunnel opens no gateway session and holds no slot of your concurrent tunnel limit. Traffic over the tailnet does not appear in the platform audit, and your organization’s maximum duration and bandwidth limit do not apply to it. The daemon records each connection in its log.

add saves the server’s hostname with the tunnel. The daemon matches it against the peers Tailscale lists: first the peer’s HostName, then the first label of its DNS name, ignoring case. If the server has a different name on your tailnet, tell the daemon:

Terminal window
reoclo tunnel edit prod-db --tailnet-host prod-1-ts

The daemon connects to the peer’s first IPv4 tailnet address. A target on the server’s loopback, such as 127.0.0.1:5432 or localhost:5432, is rewritten to that address, so the service sees an ordinary connection to its own port. A target with any other host, such as db.internal:5432, cannot be dialed this way, because only the server can resolve that name.

--via auto decides for each connection. It uses the tailnet when Tailscale is running, the peer is online, the target is eligible and the port is reachable. Otherwise it uses the relay and says why in the detail column of reoclo tunnel status. If a dial over the tailnet fails, that one connection falls back to the relay.

Terminal window
reoclo tunnel edit prod-db --via auto

The path shows relay or tailscale, whichever the last connection used.

An SSH server has no runner, so the relay cannot reach it. A tunnel to an SSH server can only use the tailnet, and add defaults it to --via tailscale.

A UDP tunnel keeps one tailnet socket for each local program that sends to it, and closes that socket after 60 seconds without datagrams. The relay applies the same rule.

Sharing publishes a saved tcp or https tunnel to the other devices on your tailnet. The daemon runs tailscale serve for it. A device can open the share if your tailnet’s access rules let it reach your machine. The traffic leaves through your Reoclo session, and nothing is published to the internet.

Sharing needs Tailscale running on your machine. It works with either transport, because the share forwards to the tunnel’s local listener.

An https tunnel appears on the tailnet at https://<machine>.<tailnet>.ts.net:<port>, with a certificate from Tailscale. Your tailnet needs HTTPS certificates turned on. Turn them on under DNS in the Tailscale admin console.

Terminal window
reoclo tunnel share grafana --tailnet
tunnel: grafana shared on the tailnet: https://laptop.example.ts.net:443 (active)

The default port is 443. Pass --port to use another one, such as 8443.

A tcp tunnel is published as a raw TCP port. The default port is the tunnel’s target port.

Terminal window
reoclo tunnel share prod-db --tailnet --port 5432
tunnel: prod-db shared on the tailnet: tcp://laptop.example.ts.net:5432 (active)
Terminal window
reoclo tunnel unshare grafana
  • Each share is a foreground tailscale serve process that the daemon starts, never a background one. It stops when the tunnel goes down (reoclo tunnel down), when you remove the tunnel, and when the daemon stops. A share never outlives the daemon or survives a reboot pointing at nothing.
  • The daemon records the process ids in run/shares.json inside its state directory. A daemon that starts after a crash stops any it finds there.
  • A share that exits restarts on its own, after a delay that doubles up to 30 seconds. The DETAIL column of reoclo tunnel status shows why it is not up.
  • For an https tunnel, tailscale serve forwards to a plaintext listener on 127.0.0.1 that the daemon keeps for the tunnel. Its port is saved in tunnels.yaml as share.internal_port, so it stays the same.
  • Sharing restarts the tunnel, so connections that are open end.
  • The SHARED column shows the address once the share is up, and its state before that.

A saved share looks like this in tunnels.yaml:

- name: grafana
kind: https
target: 127.0.0.1:3000
hostname: grafana.prod-1.reoclo.localhost
via: reoclo
share:
tailnet: true
port: 443
internal_port: 18443

An agent that uses reoclo mcp needs your approval to share or unshare a tunnel, because a share widens who can reach the server. It can still close a tunnel on its own. See Approvals.

Detail shownCause and fix
Tailscale is not installed on this machineThe daemon found no tailscale command. Install Tailscale, or set REOCLO_TAILSCALE_PATH
Tailscale is not running (Stopped)Start Tailscale and sign in. The next connection works, and a share starts on its own
no tailnet peer is named "prod-1"The server’s name on the tailnet differs. Set it with --tailnet-host
prod-1 is offline on the tailnetThe server’s Tailscale node is offline. With --via auto the tunnel uses the relay meanwhile
port 5432 listens only on 127.0.0.1 on the serverThe service is not reachable from the tailnet. Bind it to 0.0.0.0, or use --via reoclo or --via auto
the target host db.internal is not loopbackOnly the server can resolve that name. Target 127.0.0.1 on the server, or use the relay
could not dial 100.x.y.z:5432 over the tailnetThe peer is up but nothing answered. Check the service and the tailnet’s access rules
HTTPS certificates are not enabled for this tailnetTurn on HTTPS certificates under DNS in the Tailscale admin console, or share a tcp tunnel
port 443 is already served on this machine by tailscale serveSomething else publishes that port. Pick another with --port, or stop that share
the share's internal port is already in useAnother program holds the loopback port saved for the share. Free it, or run reoclo tunnel unshare <name> and share the tunnel again to get a new port