OpenClawSkills
GitHub
Gateway / Operations • TutorialHeader.readTime

Bonjour Discovery

Bonjour/mDNS discovery + debugging (Gateway beacons, clients, and common failure modes)

OpenClaw uses Bonjour (mDNS / DNS‑SD) as a **LAN‑only convenience** to discover an active Gateway (WebSocket endpoint). It is best‑effort and does **not** replace SSH or Tailnet-based connectivity.

Tutorial.step

Wide‑area Bonjour (Unicast DNS‑SD) over Tailscale

If the node and gateway are on different networks, multicast mDNS won't cross the boundary. You can keep the same discovery UX by switching to **unicast DNS‑SD** ("Wide‑Area Bonjour") over Tailscale.

High-level steps:

  1. Run a DNS server on the gateway host (reachable over Tailnet).
  2. Publish DNS-SD records for _openclaw-gw._tcp under a dedicated zone (example: openclaw.internal.).
  3. Configure Tailscale **split DNS** so your chosen domain resolves via that DNS server for clients (including iOS).

OpenClaw supports any discovery domain; openclaw.internal. is just an example.

iOS/Android nodes browse both local. and your configured wide‑area domain.

Tutorial.step

Gateway config (recommended)

Json5
{
  gateway: { bind: "tailnet" }, // tailnet-only (recommended)
  discovery: { wideArea: { enabled: true } }, // enables wide-area DNS-SD publishing
}
Tutorial.step

One‑time DNS server setup (gateway host)

Bash
openclaw dns setup --apply

This installs CoreDNS and configures it to:

  • listen on port 53 only on the gateway's Tailscale interfaces
  • ~/.openclaw/dns/<domain>.db to serve a chosen domain (e.g., openclaw.internal.)

Validate from a tailnet‑connected machine:

Bash
dns-sd -B _openclaw-gw._tcp openclaw.internal.
dig @<TAILNET_IPV4> -p 53 _openclaw-gw._tcp.openclaw.internal PTR +short
Tutorial.step

Tailscale DNS settings

In the Tailscale admin console:

  • Add a nameserver pointing at the gateway's tailnet IP (UDP/TCP 53).
  • Add split DNS so your discovery domain uses that nameserver.

Once clients accept tailnet DNS, iOS nodes can browse _openclaw-gw._tcp in your discovery domain without multicast.

Tutorial.step

Gateway listener security (recommended)

The Gateway WS port (default 18789) binds to loopback by default. For LAN/tailnet access, bind explicitly and keep auth enabled.

For tailnet-only setups:

  • Set gateway.bind: "tailnet" in ~/.openclaw/openclaw.json.
  • Restart the Gateway (or restart the macOS menubar app).
Tutorial.step

What advertises

Only the Gateway advertises _openclaw-gw._tcp.

Tutorial.step

Service types

  • _openclaw-gw._tcp — gateway transport beacon (used by macOS/iOS/Android nodes).
Tutorial.step

TXT keys (non‑secret hints)

The Gateway advertises small non‑secret hints to make UI flows convenient:

  • role=gateway
  • <code>displayName=<friendly name>'</code>
  • <code>lanHost=<hostname>.local</code>
  • <code>gatewayPort=<port>'</code> (Gateway WS + HTTP)
  • gatewayTls=1 (only when TLS is enabled)
  • <code>gatewayTlsSha256=<sha256>'</code> (only when TLS is enabled and fingerprint is available)
  • <code>canvasPort=<port>'</code> (only when the canvas host is enabled; default <code>18793</code>)
  • <code>sshPort=<port>'</code> (defaults to 22 when not overridden)
  • transport=gateway
  • <code>cliPath=<path>'</code> (optional; absolute path to a runnable <code>openclaw</code> entrypoint)
  • <code>tailnetDns=<magicdns>'</code> (optional hint when Tailnet is available)
Tutorial.step

Debugging on macOS

Useful built-in tools:

Browse instances:

Bash
dns-sd -B _openclaw-gw._tcp local.

Resolve an instance (replace &lt;instance&gt;):

Bash
dns-sd -L "<instance>" _openclaw-gw._tcp local.

If browsing works but resolving fails, you're usually hitting a LAN policy or mDNS resolver issue.

Tutorial.step

Debugging in Gateway logs

The Gateway writes a rolling log file (printed on startup as gateway log file: ...). Look for bonjour: lines, especially:

  • bonjour: advertise failed ...
  • bonjour: ... name conflict resolved / hostname conflict resolved
  • bonjour: watchdog detected non-announced service ...
Tutorial.step

Debugging on iOS node

The iOS node uses NWBrowser to discover _openclaw-gw._tcp.

To capture logs:

  • Settings → Gateway → Advanced → **Discovery Debug Logs**
  • Settings → Gateway → Advanced → **Discovery Logs** → reproduce → **Copy**

The log includes browser state transitions and result-set changes.

Tutorial.step

Common failure modes

  • Bonjour doesn't cross networks: use Tailnet or SSH.
  • Multicast blocked: some Wi-Fi networks disable mDNS.
  • Sleep / interface churn: macOS may temporarily drop mDNS results; retry.
  • Browse works but resolve fails: keep machine names simple (avoid emojis or punctuation), then restart the Gateway. The service instance name derives from the host name, so overly complex names can confuse some resolvers.
Tutorial.step

Escaped instance names (\032)

Bonjour/DNS-SD often escapes bytes in service instance names as decimal \DDD sequences (e.g. spaces become \032).

  • This is normal at the protocol level.
  • UIs should decode for display (iOS uses BonjourEscapes.decode).
Tutorial.step

Disabling / configuration

  • OPENCLAW_DISABLE_BONJOUR=1 disables advertising.
  • gateway.bind in ~/.openclaw/openclaw.json controls the Gateway bind mode.
  • OPENCLAW_SSH_PORT overrides the SSH port advertised in TXT.
  • OPENCLAW_TAILNET_DNS publishes a MagicDNS hint in TXT.
  • OPENCLAW_CLI_PATH overrides the advertised CLI path.
Tutorial.step

Related docs

  • Discovery policy and transport selection: [Discovery](/gateway/discovery)
  • Node pairing + approvals: [Gateway pairing](/gateway/pairing)