Skip to content

mDNS responder claims the machine's own hostname, so macOS renames its Local hostname to <name>-2 #229

Open

Description

@stevbev

Summary

nvpair-shared/mdns publishes A records whose owner name is the machine's own hostname (<os.Hostname()>.local), sets the cache-flush bit on them, and answers any query for that bare name with AA=1. It never probes the name first and has no conflict handling. On macOS the operating system's own mDNSResponder publishes that same name for that same machine, also cache-flushed. PAIR is therefore a second responder asserting authority over the operating system's host name.

The reported symptom is that macOS rewrites the computer's Local hostname from indigo to indigo-2 — the rename RFC 6762 §9 prescribes for a responder that loses contention for a host name. Nothing here needs to be configured on the Mac to work around it: the record that does not belong to PAIR is PAIR's.

What is on the wire

Passive capture on 224.0.0.251:5353 plus targeted queries — 3184 packets / 12008 parsed records / 211.95 s (2026-11-21, 20:23:04–20:26:36 local), live installed PAIR, no test run in progress, one IPv4 interface (en0). Both claimants for indigo.local:

Claimant Records seen for A indigo.local
macOS mDNSResponder 125 × ttl=4500 cf=1 on en0 (each alongside NSEC ttl=4500 cf=1 for the same name), 18 × on lo0 with 127.0.0.1/127.0.0.2, plus 28 × AAAA
nvpair-node-scanner (PAIR) 448 × ttl=120 — 3 with cf=1 in its 60 s announcements (AA=1, ANSWER section, t=42.50/102.51/162.51), 445 with cf=0 almost all piggybacked in the Additional section of browse/lookup answers, 9 of them direct answers to queries for the bare name
PAIR's SRV 439 × SRV with target=indigo.local.

All of these came from this one host, and the addresses agree — both sides say 10.108.6.189. The ownership assertions do not, and neither does the TTL.

The mechanism that keeps the operating system reacting is RFC 6762 §6.6, "Cooperating Multicast DNS Responders", which is explicit about the case where the rdata match: "If the TTL of B's resource record given in the message is less than half the true TTL from A's point of view, then A MUST mark its record to be announced via multicast. Queriers receiving the record from B would use the TTL given by B and, hence, may delete the record sooner than A expects. By sending its own multicast response correcting the TTL, A ensures that the record will be retained for the desired time." PAIR asserts the identical rdata at TTL 120; macOS's own TTL for that record is 4500; 120 is far below half of 4500, so macOS is obliged to re-announce, and PAIR's reannounceEvery = 60s timer (responder.go:61) hands it a new reason every minute, each announcement arriving as a burst of records. Measured over the window, macOS re-announced its own hostname A record continuously at ~0.2–3.6 s intervals for all 212 s. I can show the OS in a permanent defensive correction loop and name the rule driving it; I cannot attribute the exact sub-second spacing to a single clause, and I am not claiming to.

Note on attribution, since it matters for every number above: the source address cannot distinguish the two responders — both bind UDP 5353 on this host, so both send from 10.108.6.189:5353, and packets addressed to 224.0.0.251 reach my sniffer either way. Attribution here is by TTL, which is a clean discriminator on this link (4500 s is macOS's hostname-record TTL, 120 s is PAIR's recordTTL at responder.go:56) and is corroborated wherever the code settles the question independently — for example all 28 AAAA records for indigo.local are ttl=4500, and shared/mdns/responder.go contains no AAAA or IPv6 code at all, so those are unambiguously the operating system's.

This is not a one-machine quirk. The same capture saw all four PAIR nodes on the LAN doing the same thing for their own names: amber 1447 A records + 725 SRV targets, ochre 423 + 423, mauve 417 + 417, indigo 448 + 439 — 2735 hostname A records in 212 s, from application code, for names the operating systems own.

Where PAIR does this

All line numbers below are against origin/develop at the time of the capture.

services/shared/mdns/responder.go:

  • :123-128 — hostName is os.Hostname() + "." + domain + ".", i.e. exactly Sharing → Local hostname. There is no override; a rename needs a process restart.
  • :400-410, :433-445 — that name becomes both the SRV target and the owner name of the A records. Addresses are correctly scoped per interface (addrsForResponse, :451-457), so PAIR's rdata match the OS's, which is why the steady state is stable (§below).
  • :489-512 + :465-487 — sendAnnouncement emits the hostname A/SRV/TXT with cache-flush set (:502-505), at startup, on every address change and every reannounceEvery = 60s (:62) at recordTTL = 120 (:56).
  • That 60 s timer is a standards violation independent of the hostname question. §8.3: "A Multicast DNS responder MUST NOT send announcements in the absence of information that its network connectivity may have changed in some relevant way. In particular, a Multicast DNS responder MUST NOT send regular periodic announcements as a matter of course." PAIR's re-announce is a periodic announcement as a matter of course, on a fixed timer, with no change to report. (I would file this separately from the hostname claim: it is wrong for PAIR's own service records too, and fixing the hostname claim does not fix it.)
  • The cache-flush bit compounds it. §8.3 reserves the bit for "records that have been verified to be unique in the previous step" — i.e. records that completed §8.1 probing. PAIR sets cf=1 on the hostname A/SRV/TXT in its announcements (:502-505) having never probed that name, so it asserts the semantics "I verified this name is mine alone" for a name it does not exclusively own.
  • :353-357 — answers any A/ANY query for the bare hostname, not just its own _nvpair-node instance, with AA=1 (:331) and cf=0.
  • :334-341, :370-374 — a question with the QU bit is answered by unicast, so PAIR will answer a probe for the Mac's own name. Note this path is code-verified only: the capture contains no unicast-destination packets at all, which is expected, because RFC 6762 §15.1 says unicast UDP packets are "typically delivered only to the first socket to bind to that port", so QU responses and other unicast packets "will be received only by the first Multicast DNS responder and/or querier on a system". My sniffer was itself bound to 5353, so it structurally cannot see them.
  • There is no RFC 6762 §8 probing, no conflict detection and no tie-breaking anywhere in the package. git log -S confirms PAIR has never registered through the system mDNSResponder, so from Apple's side every one of these announcements is a foreign responder on the link.

Advertiser: services/nvpair-node-scanner/daemon.go:322 (instance, _ := os.Hostname()) → :345 (mdns.NewResponder), the only production construction site.

What the standard says

  • §8.1 (records desired unique): "it MUST send a Multicast DNS query asking for those resource records, to see if any of them are already in use. The primary example of this is a host's address records, which map its unique host name to its unique IPv4 and/or IPv6 addresses."
  • §10.2: "The cache-flush bit MUST NOT ever be set in any shared resource record. To do so would cause all the other shared versions of this resource record with different rdata from different responders to be immediately deleted from all the caches on the network." PAIR sets it on a name the OS is equally asserting.
  • §6.6 ("Cooperating Multicast DNS Responders") is the rule that governs the state actually observed here, and it is worth quoting rather than paraphrasing, because it is the opposite of a conflict: same name/type/class with identical rdata requires "no action" unless the received TTL is "less than half the true TTL", in which case the affected responder "MUST mark its record to be announced via multicast … By sending its own multicast response correcting the TTL, A ensures that the record will be retained for the desired time." The section closes: "These rules allow multiple Multicast DNS responders to offer the same data on the network (perhaps for fault-tolerance reasons) without conflicting with each other." So identical-rdata co-ownership is explicitly tolerated as data — what it does not license is two responders each asserting the name as uniquely its own, which is what the cache-flush bit asserts.
  • §9 (Conflict Resolution): "A conflict occurs when a Multicast DNS responder has a unique record for which it is currently authoritative, and it receives a Multicast DNS response message containing a record with the same name, rrtype and rrclass, but inconsistent rdata … resource records with identical rdata are never considered inconsistent, even if they originate from different hosts." On conflict the responder "MUST immediately reset its conflicted unique record to probing state … The protocol used in the Probing phase will determine a winner and a loser, and the loser MUST cease using the name, and reconfigure." The prescribed remedy is "appending the digit '2' to the name, or incrementing a number at the end of the name if one is already present", probed again, then "record this newly chosen name in persistent storage". That is precisely the -2 rename, and precisely what PAIR's behaviour invites.
  • §14: "addresses in IPv4 or IPv6 address records in Multicast DNS responses MUST be valid for use on the interface on which the response is being sent", and "In the event of a name conflict on any interface, a host should configure a new host name, if it wishes to maintain uniqueness of its host name."
  • §6.2: a responder publishing only one address family for a name "SHOULD" place "the appropriate NSEC record" alongside it. PAIR answers for indigo.local with AA=1, no AAAA and no NSEC, while macOS publishes AAAA for that name — so PAIR's cache-flushed answers degrade the OS's fate-shared address set in every peer cache on the link.
  • §15.4: "this document encourages implementers to design systems with a single Multicast DNS implementation that provides Multicast DNS services shared by all clients on that machine." macOS and Linux both ship exactly one system responder that owns the host's address records; applications register services through it (DNSServiceRegister; Avahi over D-Bus, where disable-user-service-publishing still lets "Avahi … still publish address records and suchlike but will not allow user applications to publish services"). PAIR bypasses the system responder entirely and publishes address records of its own. That is the structural mistake here; there is no supported way for an application and the OS to co-own one hostname.

Why automated test runs trigger it and ordinary running mostly does not

Ordinary running is almost benign for a specific, standards-recognisable reason: PAIR's rdata coincide with the OS's, and §9 says identical rdata "are never considered inconsistent". Nothing forces either side to concede, so the name keeps working and the developer only sees the traffic cost above. What makes a test run different is anything that puts different rdata under the OS's name:

  • The cross-process tests advertise peers with grandcat/zeroconf, which defaults the SRV target to os.Hostname() (server.go:47) and announces on every up-and-multicast interface (server.go:57-59 → connection.go:99-115, loopback not excluded). Register builds AddrIPv4 as the union of all those interfaces' addresses (server.go:62-66) and appendAddrs then publishes that union on every interface (server.go:601-610). On a Mac with a Thunderbolt bridge or any second multicast-capable interface carrying an address, a stub announces A <hostname>.local with addresses the OS does not publish on that interface — a direct §14 violation and a genuine §9 rdata conflict, which is the one condition the OS is obliged to treat as a conflict and resolve by renaming. Seven such sites: tests/discovery_test.go:27,70,113, tests/broker_test.go:115, tests/ghost_node_test.go:84, tests/cluster_data_plane_test.go:150, tests/models_http_test.go:91.
  • go test ./... also drives a separate broker per test — 55 spawn sites in services/tests alone (startBrokerWith*, startBroker, startBrokerInDir, startBrokerProc), each supervising its own scanner and therefore its own responder. Nothing in the harness disables the scanner or mDNS; the brokers get only --scanner-path and --cluster-dir (broker_supervision_test.go:74). Dozens of sequential responders, each asserting the developer's machine name, none of them probing.
  • Teardown is worse than startup. PAIR's goodbye retracts only the PTR (responder.go:516-531); nothing ever sends the hostname A at TTL 0, so each of those processes leaves a hostname record in every cache on the link for the full TTL (§10.1: the host "SHOULD send an unsolicited Multicast DNS response packet, giving the same resource record name, rrtype, rrclass, and rdata, but an RR TTL of zero"). zeroconf does the opposite and does it aggressively: Shutdown() (server.go:196) → unregister() (:593, :598) → composeLookupAnswers(resp, ttl=0, …, flushCache=true) → appendAddrs (:601) sets the cache-flush bit (:621), so every stub teardown multicasts "the mapping for <hostname>.local no longer exists — flush it", addressed to the machine that actually owns that name.

What this capture does not establish

I want to be explicit about the boundary between evidence and inference:

  • No packet in this capture contains indigo-2.local or any other -2 name (grep: 0 hits), and no record for indigo.local was seen at TTL 0 — nothing shut down or renamed during the 212 s. The capture proves the contention, not the rename event.
  • Per §9, a rename requires an inconsistent-rdata conflict or a failed probe. In this capture the rdata coincided, so no conflict was due — which is consistent with the report that ordinary running mostly does not rename while test runs do.
  • Which specific responder and record produced the inconsistency in the reporter's session is therefore not pinned. The zeroconf all-interface union above is the identified mechanism with a normative hook (§14 + §9); it is not yet demonstrated on the wire.
  • Whether the other PAIR nodes on this LAN have also been renamed is untested. Whether macOS consumes the lo0 announcements is untested.

A staged experiment (one variable per arm: PAIR responder alone, zeroconf stub alone, both; each with mDNSResponder logging plus a capture) would settle it. It requires changing this Mac's hostname under test, so it was not run unattended.

Proposed fix (ranked)

  1. Stop claiming the machine's hostname; claim a PAIR-owned synthetic name. Build the SRV target as nvpair-<uuid12>.local — twelve hex digits of the already-persisted per-host UUID (services/shared/nodeid/nodeid.go:37-60, already resolved in the scanner at daemon.go:312 and already published as TXT uuid=) — and publish A records only under that name. Twelve digits rather than eight: eight is the leading 32 bits, whose birthday bound is ~2^16 hosts, and 19 bytes costs nothing against the 63-byte label limit. The OS is no longer a rival claimant for its own name; the target still resolves for third-party Bonjour browsers; PAIR's own consumers are unaffected — every dial, display and trust path uses the TXT ip=/ips= addresses or the mDNS instance name, never the SRV target (directory.go:46 projects Name: raw.ID, i.e. the instance name).

    Two details that matter if this is taken: the label must never fall back to os.Hostname(), because that is the defect. nodeid.Resolve() can return "", and it discards its own persist error, so the naming rule needs a defined answer — hostname-derived hash if the UUID is missing, and advertise nothing if both are unavailable, rather than emit a no-entropy label every host on the path would share. A read-only config directory makes the UUID re-mint per boot, which no naming rule can detect; logging whether the identity was read or minted is the only way that stays diagnosable.

  2. Extend the goodbye to SRV/TXT/A (responder.go:516-531) so a stopping process withdraws what it claimed instead of leaving a cache-flushed record for the TTL to expire.

  3. Make the test stubs stop claiming the hostname: zeroconf.RegisterProxy with an explicit synthetic host and explicit IPs (server.go:84-86) instead of Register, at the seven measured sites — discovery_test.go:27,70,113, broker_test.go:115, ghost_node_test.go:84, cluster_data_plane_test.go:150, models_http_test.go:91 — so a test run contributes no claims for the developer's own machine name and no all-interface address unions.

  4. Exclude the SRV target from DiscoveryRecordID (directory.go:67). Not optional if (1) is done — see the cost analysis below, and note that (1) and (4) travel together.

  5. Optional hardening: §8 probing plus §9 conflict handling in shared/mdns, and/or a guard so two local responders cannot claim one name. Probing costs ~2 s before the first announcement. This is defence in depth, not the fix: (1) removes the claim entirely, so the result is trigger-agnostic.

Cost of (1), and how to make it zero

nvpair-node-scanner/directory.go:64-70 hashes raw.ID + raw.Host (the SRV target) + ni port + sorted addresses into DiscoveryRecordID, and directory_test.go:298-300 pins that behaviour. Under (1) the SRV target is the only one of those inputs that changes — the instance name still comes from os.Hostname(), and the port and addresses are untouched — so whether this change has any record-ID effect is entirely a question of whether raw.Host stays in that hash.

If it stays in, the effect is real. DiscoveryRecordID is a key, not a label: the directory key for unverified entries (directory.go:94-99), the discovery browser's keyFunc (daemon.go:343, and a changed key emits Remove + Add rather than Updated — shared/discovery/discovery.go:377 only emits Updated when the key survives), the hardware-preview candidate and retry-backoff maps (hardware_previews.go:40,45,54,70-72,99), the broker's store key for unverified discoveries (nvpair-ui-broker/discovery.go:119,140), and the desktop's row key for unverified nodes (modular-state.ts:825). Every observer in the fleet re-keys every unverified peer once per node upgrade, and a node in hardware-preview backoff gets a fresh run of retries.

If it comes out, there is no record-ID effect at all: every unverified record ID is byte-identical before and after. That is the whole reason to prefer (4) over leaving the hash alone, and it beats the alternative of shipping the churn and writing it up as an acceptable migration.

Two things worth stating precisely, because they bound the risk:

  • Pairing and trust are not at stake either way. For a pinned or verified node the DiscoveryRecordID field is repurposed to hold clustertrust.Mesh.PeerRecordID (daemon.go:647), which is sha256(own leaf DER) : sha256(peer leaf DER) : ClusterID : Epoch : pinKey (mesh.go:159-177) — no hostname, no SRV target, no mDNS content. Every check that guards a pin (daemon.go:598,605,613,623; nvpair-ui-broker/discovery.go:872) is blind to what the announcement's target says.
  • Only unverified records are involved. The broker forces them untrusted (discovery.go:455) and "an unverified advertisement cannot create a scheduling target" (discovery.go:399), so proxy addressing, workloads, errors and cluster-manager are not in scope at all. I had previously written that this churn would reach those services; that was wrong, and it is worth correcting since it was the main argument for accepting the churn.

Independently of cost: with a UUID-derived target, hashing raw.Host puts the claimed UUID into an id whose own comment (directory.go:57-58) says it identifies "a connection candidate, not its claimed owner", and whose protecting test (directory_test.go:277-279) asserts that uuid= and cluster-uuid= claims must not change it. A UUID-derived target re-opens exactly the door that test closes. And if the config directory is read-only, a per-boot re-minted UUID would move that node's record ID every boot, forever. So (4) is the right change even where the rollout cost is zero — with one implementation note: directory_test.go:298-300 should be inverted into a positive invariant (different target, same instance/port/addresses ⇒ same id) rather than deleted, otherwise nothing stops the field being added back.

How to verify a fix

Passive capture is enough — no rename needs to be provoked. After the fix, zero packets on the link should carry an A record named <os.Hostname()>.local from PAIR (today: 448 from this host, 2735 across the four PAIR nodes per 212 s), with nvpair-<uuid12>.local announcements in their place. dns-sd -L <instance> _nvpair-node._tcp local should still resolve, and dns-sd -Q <hostname>.local A should return only the operating system's own records.

If the SRV target is excluded from DiscoveryRecordID as proposed, a mixed-version check is worth adding to the same verification: with one old and one new node running, neither side should log a remove-then-add for the other. That assertion is what keeps the hash change from being quietly reintroduced later, and it fails immediately if raw.Host goes back into directory.go:67.

Environment

macOS (Apple Silicon), PAIR installed from /Applications/NVIDIA PAIR.app, single IPv4-bearing interface en0, four PAIR nodes on the LAN. Reproduced against a clean develop-tip checkout. Related to, but independent of, the cross-process test work in #226: the tests multiply the claimants and add the all-interface unions that make a real conflict, they do not cause the underlying behaviour. Hostnames and IP addresses in this issue are pseudonymized for publication; every packet count is from the unmodified capture.

Activity

  1. stevbev commented on Nov 24, 2026

    @stevbev
    ContributorAuthor

    Body edited 2026-11-23: paraphrased RFC references replaced with verbatim quotes checked against RFC 6762; record counts re-derived from the raw capture (one earlier figure counted query-section entries as answers, and a parsed-record total replaced an estimate); hostnames and addresses pseudonymized for publication. No change to the analysis, findings, or proposed fixes.

  2. added a commit that references this issue on Nov 24, 2026
    b1ae820
  3. added a commit that references this issue on Nov 25, 2026
    de6ce32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions