Skip to content

fix: a DNS preset goes to the adapter Windows sends its traffic through, and the confirmation names it - #2937

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/dns-preset-follows-the-best-route
Oct 21, 2026
Merged

laurentiu021 merged 1 commit into
mainfrom
fix/dns-preset-follows-the-best-route

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Closes #2879.

Confirmed in the selector: every DNS path on the tab, the Current DNS readout, the capture before a change, Set, Reset to DHCP and the fallback of Undo, picked the first adapter that is up and not virtual, ordered by ifIndex, which is the order adapters were created in. Nothing asked which adapter carries the traffic. I could not reproduce the dock case here, with one physical adapter up; the integration tests give the selector a Wi-Fi at interface 5 and a dock's Ethernet at 17 carrying the route.

The changes:

  • ActiveAdapterSelector, the one rule all of them share, reads the adapters that are up once, asks Find-NetRoute for the route to a public IPv4 address and, without one, a public IPv6 address, and takes the adapter of that route's interface. Find-NetRoute works the route out from the table and sends nothing. Only when there is no route to an adapter that is up does it fall back to the old order, first non-virtual adapter by ifIndex, then any. On this PC, through the real cmdlets, it picks the same adapter as before, the only physical one up.
  • Undo is unchanged: it restores the adapter its snapshot pinned by GUID.
  • The capture prints IFNAME= with the adapter's name, DnsSnapshot.AdapterName carries it, and the confirmations read "Change DNS on the network adapter "Ethernet 3" to …" and "Reset DNS on the network adapter "Ethernet 3" to automatic (DHCP)?". The name only labels: identity stays the GUID and index, and it is never put into a script. Without a name the text falls back to "network interface 12".

Docs

README, DNS & Hosts: the change goes to the adapter Windows sends its traffic through, the confirmation names it, and Current DNS reads that same adapter.

Tests

  • New in DnsScriptTests (integration), now with Find-NetRoute shadowed in every test so the machine's own routes never answer: the index is the best route's adapter, 17, not the lowest number, 5; an IPv6-only route is followed too; with no route, or a route to an interface that is not an adapter that is up, it is the first adapter up; and Current DNS lists the servers of the route's adapter, not the Wi-Fi's.
  • New in DnsServiceTests: the capture prints the name and keeps it whole, an = in it included; a capture without a name gives an empty one.
  • New in DnsHostsViewModelTests: Change and Reset name the adapter as Windows does.
  • Red before the fix, green after, each undone on its own: the lowest interface number again (three integration tests), only an IPv4 route looked for, the route's interface taken whether or not it is an adapter that is up, the confirmation naming the number, and the capture printing no name.
  • Run locally, twice: DnsServiceTests, DnsHostsViewModelTests, DnsHostsViewModelGateTests, ArchitectureTests and InclusiveTermsTests (400), and DnsScriptTests (12). All four projects build with 0 warnings, and dotnet format --verify-no-changes is clean.

…gh, and the confirmation names it

- DnsService's adapter selector takes the interface of the route Find-NetRoute finds to a public IPv4 address, then a
  public IPv6 one, among the adapters that are up, and falls back to the old order, the first non-virtual adapter up
  by ifIndex, only without such a route. The lowest ifIndex is only the order adapters were created in, so on a
  laptop on a dock a family preset went to the Wi-Fi while names resolved through the Ethernet's servers.
- The capture prints the adapter's name, DnsSnapshot.AdapterName carries it, and the Change and Reset confirmations
  say "the network adapter "Ethernet 3"" instead of an interface number.
@laurentiu021
laurentiu021 merged commit 4f9bfc6 into main Oct 21, 2026
6 checks passed
@laurentiu021
laurentiu021 deleted the fix/dns-preset-follows-the-best-route branch October 21, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant