reoclo hosts
reoclo hosts lsreoclo hosts add <name>...reoclo hosts rm <name>...reoclo hosts syncreoclo hosts setup [--allow-suffix <suffix>]... [--port-443]reoclo hosts uninstallreoclo hosts manages the hostnames that resolve to your machine and lead to a saved tunnel. Every hostname maps to 127.0.0.1 and ::1.
Writing /etc/hosts needs root, and the tunnel daemon runs as your user. A small helper does that one job. You install it once with reoclo hosts setup, which asks for sudo. Without the helper, https tunnels still work in programs that resolve .localhost names themselves. Programs that use the system resolver, such as Safari, need the hosts entries.
What goes in the hosts file
Section titled “What goes in the hosts file”The helper keeps a managed block between two marker lines and leaves every other line alone:
# BEGIN reoclo (managed)127.0.0.1 grafana.prod-1.reoclo.localhost::1 grafana.prod-1.reoclo.localhost# END reocloThe block holds the hostname of every saved tunnel, up or down, plus the manual hostnames you add. The daemon sends the full list to the helper whenever a hostname changes. When the helper is not installed, the daemon skips the step and tunnels work as before. When the helper refuses or fails, reoclo hosts ls and reoclo hosts sync show the reason, and the tunnels keep running.
Lists every hostname in the block with the tunnel that owns it, or manual. The last line shows the helper: whether it is installed, how many entries it holds, and whether the port 443 relay is on. With -o json it prints one object per hostname.
$ reoclo hosts lsHOSTNAME SOURCEgrafana.prod-1.reoclo.localhost grafanascratch.localhost manualhelper: installed, 2 entries in /etc/hosts, port 443 relay offadd <name>... and rm <name>...
Section titled “add <name>... and rm <name>...”add adds hostnames that point at loopback with no tunnel behind them, for example a name you serve yourself on your machine. rm removes hostnames you added this way. A tunnel’s hostname goes away with the tunnel, so rm refuses it. remove and delete also work in place of rm, and list in place of ls.
A hostname must be a lowercase DNS name that ends in .localhost or in a suffix you allowed with reoclo tunnel trust --domain.
Sends the full hostname list to the helper again. It exits with code 1 when the helper is missing or reports an error, so you can use it in scripts.
Installs the helper. Run it as your own user; it re-runs the reoclo binary under sudo.
| Option | Meaning |
|---|---|
--allow-suffix <suffix> | Let the helper write names under this suffix, such as internal. Repeat for more |
--port-443 | Relay 127.0.0.1:443 and [::1]:443 to the HTTPS port, so URLs drop the port |
Setup needs the released reoclo binary, because the helper runs from a root-owned copy of it. It does not run from a source checkout.
What it installs:
| macOS | Linux | |
|---|---|---|
| Helper binary | /Library/PrivilegedHelperTools/com.reoclo.hostsd | /usr/local/libexec/reoclo-hostsd |
| Root-owned config | /Library/Application Support/Reoclo/hostsd.json | /etc/reoclo/hostsd.json |
| Service | /Library/LaunchDaemons/com.reoclo.hostsd.plist | /etc/systemd/system/reoclo-hostsd.service |
| Socket | /var/run/reoclo/hostsd.sock | /run/reoclo/hostsd.sock |
Run setup again to change the allowed suffixes or the relay. It replaces the copy of the binary, so run it again after you upgrade the CLI if you want the helper to follow.
One configuration directory
Section titled “One configuration directory”The helper writes one block for the whole machine, so it serves the default configuration directory only. With $REOCLO_CONFIG_DIR set, reoclo hosts setup refuses and the daemon leaves /etc/hosts alone.
What the helper accepts
Section titled “What the helper accepts”- Loopback only. A request has no field for an address. Every entry maps to
127.0.0.1and::1. - Allowed names only. Each hostname must be a subdomain of
.localhost, or a suffix on the allowlist or a subdomain of one. The allowlist lives in the root-owned config, so changing it needssudo. A process running as your user cannot pointgithub.comat your machine. - At most 512 hostnames per request.
- Only your user. The socket sits in a directory owned by you with mode 0700, and the socket has mode 0600.
- Only its own block. It rewrites the hosts file through a temporary file and a rename, keeps the file’s owner and mode, and changes only the lines between the markers. If the block is damaged (a missing or repeated marker), it refuses to touch the file.
On macOS the helper then flushes the DNS cache.
Custom suffixes need two steps
Section titled “Custom suffixes need two steps”A custom hostname such as grafana.internal needs the suffix in two places, because two different things check it:
reoclo tunnel trust --domain internal # the CA may sign for itreoclo hosts setup --allow-suffix internal # the helper may write itPort 443
Section titled “Port 443”By default the URL carries :8443, because an ordinary user cannot bind port 443. --port-443 makes the helper listen on 127.0.0.1:443 and [::1]:443 and relay the bytes to the HTTPS port that tunnels.yaml named at setup time. URLs then drop the port. The relay forwards only to that recorded port. If you change https_port later, run reoclo hosts setup --port-443 again.
The relay stays off by default, and it refuses to start while another program answers on port 443. A local web server, proxy or Docker container that already serves port 443 would otherwise lose its traffic to the relay. setup --port-443 checks first and stops with an error. The helper checks again each time something talks to it, for example when you run reoclo hosts ls, so the relay starts once port 443 is free. Until then the URL keeps its port, and reoclo hosts ls shows why the relay is off.
uninstall
Section titled “uninstall”Stops the helper, removes its files and the managed block from your hosts file. It runs under sudo and needs the released reoclo binary.
Related
Section titled “Related”reoclo tunnel: saved tunnels, HTTPS tunnels and the local CA- Local HTTPS for tunnels: a walkthrough from trust to a browser tab