Repository navigation
The netbird role ranks the overlay's resolver first where resolvconf writes resolv.conf - #97
Merged
davidjalbers merged 5 commits intoDec 3, 2026
Conversation
…esolvconf writes resolv.conf (PLX-262) Red: on a Debian host whose /etc/resolv.conf is resolvconf's, with four nameservers from eth0 and NetBird's record wt0, resolvconf writes the provider's three and cuts the overlay's resolver off. The role has no task file resolvconf.yml, its main file names none, and nothing ranks wt0 or the interface it is told. The first test, the host as found, passes: it shows the cut-off in the container with the real package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…writes resolv.conf (PLX-262) resolvconf writes at most three nameservers, in the order of /etc/resolvconf/interface-order, which ranks eth* and the other named interfaces ahead of NetBird's, matched only by the last line. A host whose provider brings three or more nameservers cut the overlay's resolver off, and no overlay name resolved. Where /etc/resolv.conf links to resolvconf's own, as its package links it, the role adds a block that names NetBird's interface above the package's lines and has resolvconf write the file again at once. Ranked first, the resolver answers the overlay's zones and forwards every other name to the nameservers the host had when the daemon started. The interface is netbird_interface, NetBird's default wt0, which the role does not change. Elsewhere, and where interface-order is missing, nothing runs. The task file runs before the daemon starts, so that a host joining in the same run registers into the order already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… nothing where resolvconf does not write resolv.conf (PLX-262) Guards, green at once: a run after the package's interface-order came back ranks the overlay's resolver first again; a run on a host whose resolv.conf links to systemd-resolved's stub, is a file of its own as NetworkManager writes one, or is resolvconf's with no interface-order passes and changes neither file. Without the task's two conditions the second test fails at its first host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng other roles' handlers, and runs before the daemon starts (PLX-262) Red: a play in which an earlier task notifies a handler, then the task file runs, then later tasks read resolv.conf and look for the handler's mark. The overlay's resolver leads at once, but the earlier handler has already run: the role's flush runs every handler pending in the play. The listing test now finds the task of the imported file by its whole name and holds it before the daemon's start; it passes at this commit, and no longer passes for a task that only shares the start of the name. The container takes SYS_ADMIN alone, which unmounting Docker's resolv.conf needs, instead of --privileged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not by a flushed handler (PLX-262) resolvconf -u runs right after the block, where the block task reports a change, so the file is written again within the run and nothing waits on the end of the play. The handler and the flush are gone: the flush ran every handler pending in the play, and the role runs right after base, so other roles' handlers ran earlier than before. In check mode nothing runs, as before. ansible-lint's no-handler is set aside at that one line, with the reason above the task. The import takes a name of its own, apart from the task it brings, and the header says the forwarded nameservers are those /etc/resolv.conf held when the daemon started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
davidjalbers
deleted the
davidjalbers/plx-262-a-host-with-three-or-more-nameservers
branch
December 3, 2026 13:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The role
netbirdofplexus.hostranks NetBird's interface first in/etc/resolvconf/interface-orderwhere Debian'sresolvconfwrites/etc/resolv.conf, and hasresolvconf -uwrite the file again at once.tasks/resolvconf.yml, imported bytasks/main.ymlafter the install and before the daemon starts: a managed block (blockinfile, marker# BEGIN/END plexus.host.netbird: the overlay's resolver first) holding one pattern, the interface's name, above the package's lines./etc/resolv.confresolves to/run/resolvconf/resolv.conf(the test resolvconf's own postinst makes) andinterface-orderexists.resolvconf -uwhere the block task reported a change, so that a record NetBird registered before the run moves within the run, before the play's next task.It is a task, not a handler: a flush this early in the play would run every other role's pending handler with it.
ansible-lint's
no-handleris set aside at that one line.defaults/main.yml:netbird_interface: wt0, the name of the record the block ranks.newborns/netbird-resolvconf.test.ts: a Debian trixie container with the realresolvconfpackage (1.94), four nameservers undereth0.inet6andeth0.dhcp, and a stand-in recordwt0with the overlay's resolver and search domain.The container takes
SYS_ADMINalone, to unmount theresolv.confDocker mounts.The runner host's user-data is unchanged.
What a consumer sees when it takes the version
On a host with
netbird_enabledwhose/etc/resolv.confis resolvconf's, the next playbook run reports two changed tasks:Rank the overlay's resolver firstadds three lines at the head ofinterface-order, andHave resolvconf write resolv.conf in the new orderrewrites/etc/resolv.conf.NetBird's resolver is then the first nameserver and the overlay's domain leads the search list.
That holds on every such host, not only on one with three or more provider nameservers: on a host whose overlay resolver was third, it is now first, so every public name goes through NetBird's forwarder first (question 1).
Such a host with two provider nameservers may also have failed to resolve overlay names before: glibc ends a lookup at the first NXDOMAIN, so a provider resolver that answers NXDOMAIN for the overlay's domain never lets the third nameserver be asked (the reviewer ran this with stand-in servers; what a real provider answers is unknown, and the issue's statement that a Proxmox guest does not show the fault is itself unverified). The change may therefore repair such hosts as well as reroute their public lookups.
A delivery slot's container that already runs keeps its copy of the old file until it restarts; a new runner host runs
netbirdbeforeactions_runners, so its slots start with the new file.A second run changes nothing.
On a host where systemd-resolved, NetworkManager or a plain file owns
/etc/resolv.conf, the three new tasks reportokorskippedand nothing changes.The four questions
1. Does NetBird's resolver, ranked first, answer names outside the overlay, and how fast does glibc move on?
It forwards them.
With the resolvconf manager NetBird writes only its own address as nameserver (
applyDNSConfig,client/internal/dns/resolvconf_unix.go), and registers the nameservers it read from/etc/resolv.confat start as a handler for the root zone atPriorityFallback, skipping its own address (registerFallback,server.go).A primary nameserver group of the account, where there is one, takes all names at a higher priority.
When every upstream fails it answers SERVFAIL (
upstream.go); when no handler matches, REFUSED (handler_chain.go).glibc goes to the next nameserver at once on SERVFAIL, NOTIMP or REFUSED (
resolv/res_send.c, glibc 2.41,thisansp_error) and on an ICMP port unreachable (ECONNREFUSED, same file); only a resolver that does not answer at all costs the timeout, 5 s by default (resolv.conf(5),timeout:n).A daemon that stops cleanly removes its record (
resolvconf -d), so the provider's nameservers lead again.After an unclean exit that leaves a stale record, NetBird at its next start reads a file with its own address first, skips that address (by equality, in
registerFallback), and so forwards to the two provider nameservers that survive resolvconf's limit of three, not three (the reviewer's reading of the source; not run).Public resolution therefore keeps working; it gains one hop through the forwarder, and a hung daemon whose record stays would cost 5 s per query before the next nameserver.
I did not stop on this.
2. Is the interface always
wt0?No:
wt0is NetBird's default (client/iface/configurer/name.go),netbird up --interface-namechanges it (client/cmd/up.go), and so can an MDM policy; the profile keeps it asWgIface.The record NetBird registers is named exactly after the interface (
resolvconf -a <interface>,resolvconf_unix.go).The role never passes
--interface-nameandnetbird statusdoes not report the name, so the role does not know it; it gets a default,netbird_interface: wt0, which a host that changed the name sets alike.3. Does an upgrade of
resolvconfoverwriteinterface-order?It is a conffile:
DEBIAN/conffilesofresolvconf_1.94_all.deb(trixie) lists/etc/resolvconf/interface-order.dpkg keeps a locally changed conffile when the package's version of it did not change, and asks when it did, unless
--force-confoldor--force-confnewdecides (dpkg(1),--force-things); the collection sets neither.unattended-upgrades holds such a package back with "Package resolvconf has conffile prompt and needs to be upgraded manually" (
conffile_promptin/usr/bin/unattended-upgradeof the trixie package).resolvconf reads no other file for the order:
list-recordsreadsinterface-order, and its own built-in list only where the file is unreadable.So the role edits the conffile, but as little as it can: one block above the package's lines, the rest left as shipped, so that a prompt shows a one-hunk difference.
A person who takes the package's new file drops the block until the next playbook run writes it again; a test holds that.
Where
interface-orderis missing, the role does nothing rather than create a file of one line, which would leave every other record unlisted.4. Is the task a no-op where systemd-resolved or NetworkManager manages DNS?
Yes.
The condition is the one resolvconf's own postinst uses:
/etc/resolv.confresolves to/run/resolvconf/resolv.conf(resolvconf(8): the link "is normally created on installation of the resolvconf package").With systemd-resolved the file links to
/run/systemd/resolve/stub-resolv.conf; NetworkManager writes a file of its own; either way the block is skipped andresolvconf -unever runs.The condition reads no command, so the
resolvconfthat Debian'ssystemd-resolvedpackage provides as a compatibility command does not count.On such hosts NetBird uses those managers itself (
getOSDNSManagerType,host_unix.go).A test holds it for a link to the stub and for a file headed
# Generated by NetworkManager, by the link and the file alone, not with the daemons running.Choices the issue did not make
netbirdofplexus.host, not in the runner host's user-data, since any host on an image where resolvconf writes the file is affected (the coordinator's reading, for the maintainer to confirm or correct).lo*lines, as the fix by hand did: a local caching resolver registered underlowould otherwise come first, and resolvconf'sTRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS(default yes) would cut the overlay's resolver off behind it.wt0, notwt0*: NetBird's record has exactly that name.netbird_interfaceis a new default instead of a name read from NetBird's profile file, whose format is NetBird's own.include_rolewithtasks_from, and checks with--list-tasksthat the role's main file lists the ranking's own task beforeEnable and start the NetBird daemon; the import has a name of its own, apart from that task's.The real NetBird daemon is not installed in the test.
Not tried
d8a304a, not on a run.resolvconfwith a changed conffile; the test copies the package's file back by hand.Each was checked by breaking that code once.
Owed to the compendium
approaches/platform.md, the paragraph on thenetbirdrole, says nothing of DNS.This pull request does not change the compendium.
🤖 Generated with Claude Code