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.
Before you start
Section titled “Before you start”- 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 --jsonand treats the node as running only when its state isRunning. - 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 truetailscale_running truetailscale_https_certificates trueDial the server over the tailnet
Section titled “Dial the server over the tailnet”-
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 on127.0.0.1on the server cannot be reached this way.reoclo servers portslists each listening port with its address:Terminal window reoclo servers ports prod-1 -
Save the tunnel with
--via tailscale.Terminal window reoclo tunnel add prod-db --server prod-1 --target 5432 --via tailscaleIf the port scan shows that the port listens only on loopback,
addprints a warning and still saves the tunnel. A port the scan does not list is allowed, because the scan may be out of date. -
Check the path.
$ reoclo tunnel status prod-dbNAME SERVER KIND LOCAL TARGET STATE PATH SHARED DETAILprod-db prod-1 tcp 127.0.0.1:15432 prod-1:127.0.0.1:5432 ready tailscaleWith
-o json, thepeerfield 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.
How the daemon finds the server
Section titled “How the daemon finds the server”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:
reoclo tunnel edit prod-db --tailnet-host prod-1-tsThe 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.
Let the daemon choose
Section titled “Let the daemon choose”--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.
reoclo tunnel edit prod-db --via autoThe path shows relay or tailscale, whichever the last connection used.
SSH servers
Section titled “SSH servers”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.
Share a tunnel with your tailnet
Section titled “Share a tunnel with your tailnet”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.
Share an HTTPS tunnel
Section titled “Share an HTTPS tunnel”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.
reoclo tunnel share grafana --tailnettunnel: 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.
Share a TCP tunnel
Section titled “Share a TCP tunnel”A tcp tunnel is published as a raw TCP port. The default port is the tunnel’s target port.
reoclo tunnel share prod-db --tailnet --port 5432tunnel: prod-db shared on the tailnet: tcp://laptop.example.ts.net:5432 (active)Stop sharing
Section titled “Stop sharing”reoclo tunnel unshare grafanaHow a share lives
Section titled “How a share lives”- Each share is a foreground
tailscale serveprocess 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.jsoninside 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
DETAILcolumn ofreoclo tunnel statusshows why it is not up. - For an
httpstunnel,tailscale serveforwards to a plaintext listener on127.0.0.1that the daemon keeps for the tunnel. Its port is saved intunnels.yamlasshare.internal_port, so it stays the same. - Sharing restarts the tunnel, so connections that are open end.
- The
SHAREDcolumn 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: 18443Agents
Section titled “Agents”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.
Troubleshooting
Section titled “Troubleshooting”| Detail shown | Cause and fix |
|---|---|
Tailscale is not installed on this machine | The 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 tailnet | The 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 server | The 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 loopback | Only 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 tailnet | The peer is up but nothing answered. Check the service and the tailnet’s access rules |
HTTPS certificates are not enabled for this tailnet | Turn 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 serve | Something else publishes that port. Pick another with --port, or stop that share |
the share's internal port is already in use | Another 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 |
Related
Section titled “Related”reoclo tunnel: every option, states and the daemon- Local HTTPS for tunnels: trusted hostnames on your machine
- Runner: how the relay path works