ISSUE DESCRIPTION No split dns registered with the OS with an app connector. What is the…
- User
ISSUE DESCRIPTION
No split dns registered with the OS with an app connector.
What is the issue?
It's possible to have an app connector but tailscale fails to register split dns with the OS to route dns requests to it.
Steps to reproduce
Linux w/ systemd-resolved Turn off MagicDNS No global dns fallback results in Tailscale not being used for DNS by the operating system
Are there any recent changes that introduced the issue?
No response
OS
No response
OS version
No response
Tailscale version
No response
Other software
No response
Bug report
No response
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
- Assistant
I'll start by exploring the repository structure to understand the codebase and locate relevant files related to DNS configuration and split DNS handling. Let's first see what kind of project this is.
- Assistant
Let me get a broader view of the repository structure. Let me look at the top-level directories.
- Assistant
This is the Tailscale repository. The issue is about split DNS not being registered with the OS when using an app connector. The specific scenario is:
- Linux with systemd-resolved
- MagicDNS turned off
- No global DNS fallback
- Results in Tailscale not being used for DNS by the OS
I need to find code related to DNS configuration, split DNS, app connectors, and systemd-resolved integration. Let me search for relevant terms.
- Assistant
Let me look at the DNS manager code and related files to understand the issue better.
- Assistant
Let me understand the issue better. The problem is:
- Linux with systemd-resolved
- MagicDNS is turned off
- No global DNS fallback
- Tailscale fails to register split DNS with the OS for app connector routes
The key area seems to be in the DNS manager, particularly
net/dns/directory. Let me look at the DNS configuration logic. - Assistant
Now let me look at the
compileConfigmethod more carefully, which is responsible for generating the resolver config and OS config. Let me find it. - Assistant
Let me look at the
compileConfigfunction in detail. - Assistant
Now let me understand the issue. The issue is about split DNS not being registered with the OS when there are app connector routes but no default resolvers (MagicDNS off, no global DNS fallback). Let me look at the relevant methods in the Config type.
- Assistant
Let me look at the Config type.
- Assistant
Let me look at the config.go file to understand the Config type better.
- Assistant
Now I understand the flow. Let me look at the
compileConfiglogic more carefully. The issue is that when we have split DNS routes (like from app connector) but no default resolvers (MagicDNS off, no global DNS fallback), the OS doesn't get configured with split DNS. Let me trace through the code.Let me check what
SupportsSplitDNS()returns on Linux with systemd-resolved: - Assistant
- Assistant
Let me check if systemd-resolved supports split DNS:
- Assistant
Let me check what it returns.
- Assistant
So
SupportsSplitDNS()returns true for systemd-resolved. Now let me trace through the issue scenario. The problem is: with only split DNS routes (from app connectors), but no default resolvers and no MagicDNS, the OS might not be getting configured properly. Let me look at how DNS config gets compiled from the node's perspective. - Assistant
Let me look at how DNS configuration is compiled from the node backend.
- Assistant
Let me look at how the DNS config is built, particularly how app connector routes are set up:
- Assistant
Let me search for the dnsconfig file.
- Assistant
There's no
dnsconfig.go, only adnsconfig_test.go. Let me look for where DNS configuration is being created. - Assistant
Let me look at the
dnsConfigForNetmapfunction: - Assistant
Let me see the rest of this function.
- Assistant
Now I see something interesting. Let me look at the last part of
dnsConfigForNetmap: - Assistant
Let me see the rest of this function:
- Assistant
Let me look at the test file for DNS configuration to understand the expected behavior better.
- Assistant
Let me look at the test file for relevant test cases.
- Assistant
Now let me understand the issue better by looking at the
compileConfigpath for app connector routes. The key issue is that app connector routes use DoH-style resolvers (likehttp://100.x.x.x:1234/dns-query). Let me trace through thecompileConfigpath. - Assistant
Let me look at how the resolved manager uses the OS config:
- Assistant
Let me look at how the resolved manager handles MatchDomains and Nameservers:
- Assistant
Now I understand the issue. Let me trace through the
compileConfigflow for app connector routes (which use DoH-style resolvers likehttp://100.x.x.x:1234/dns-query):singleResolverSet()returns the resolver set if all routes point to the same resolvers- On Linux with systemd-resolved,
SupportsSplitDNS()returns true - So we enter:
ocfg.Nameservers = toIPsOnly(cfg.singleResolverSet()) - But
toIPsOnlyfilters out non-IP:port resolvers, so for DoH URLs it returns empty ocfg.MatchDomains = cfg.matchDomains()is set but with empty nameserversrcfg.Routesis NOT set (we return early without setting it)
This means:
- OS gets empty nameservers but non-empty match domains
- Internal resolver doesn't get the routes
Let me look at the manager test to confirm this understanding:
- Assistant
Let me look at the test cases related to split DNS and routes:
- Assistant
Let me look at the test cases for split DNS with routes only (no default resolvers):
- Assistant
Let me look at the "routes" test case and the "routes-split" test case to understand the expected behavior:
- Assistant
Now let me look at what
RoutesRequireNoCustomResolversdoes: - Assistant
Now let me look at the specific test case for app connector routes to understand the resolver format:
- Assistant
Now I understand the issue. Let me look at how
toIPsOnlyworks with URL-style resolvers: - Assistant
Now I understand the issue clearly. Let me trace through the problematic scenario:
- App connector creates split DNS routes with URL-based resolvers (e.g.,
http://100.x.x.x:1234/dns-query) - MagicDNS is off, no global DNS fallback
- In
compileConfig, the code checkssingleResolverSet()> 0 ANDSupportsSplitDNS()is true - It calls
toIPsOnly()on URL-based resolvers, which returns empty (since URLs aren't IP:port 53) - OS gets configured with
Nameservers=[]andMatchDomains=[example.com]but no actual resolver - The resolver config (
rcfg) doesn't get the routes either since we returned early
This means the OS is told to route those domains to Tailscale but has no nameserver to handle them, and the internal resolver doesn't know about the routes either.
Let me look at the
singleResolverSetcheck more carefully and verify my understanding: - App connector creates split DNS routes with URL-based resolvers (e.g.,
- Assistant
Now I have a clear picture. The issue is:
- When split DNS routes use URL-based resolvers (from app connectors),
toIPsOnly()returns empty because URLs aren't plain IP:port - On Linux with systemd-resolved (which supports split DNS), the code takes the "let the OS handle split DNS" path
- The OS gets configured with
MatchDomainsbut emptyNameservers, which is broken - The internal resolver doesn't get the routes either since we returned early
The fix: when
toIPsOnly()returns empty for asingleResolverSet(), we should fall through to the quad-100 proxy path instead.Let me also check how
RoutesRequireNoCustomResolversworks: - When split DNS routes use URL-based resolvers (from app connectors),
- Assistant
Now I have a complete understanding. Let me now look at the test infrastructure for the DNS manager to write a test:
- Assistant
Now let me look at the full test runner function and the existing test case that's closest to the issue scenario.
- Assistant
Now let me look at the test runner function:
- Assistant
Now I have a clear understanding of the issue. Let me trace through the specific scenario:
Scenario: Linux with systemd-resolved, MagicDNS off, no global DNS fallback, but app connector provides split DNS routes (with DoH URLs like
http://100.x.x.x:1234/dns-query).In
compileConfig:needsOSResolver()is true (has routes)- No default resolvers, so none of the first three switch cases match
- Falls through to the split DNS section
singleResolverSet()returns the DoH resolver set (non-empty)SupportsSplitDNS()is true for systemd-resolvedtoIPsOnly(cfg.singleResolverSet())returns empty because DoH URLs aren't IP:port 53ocfg.Nameservers= empty,ocfg.MatchDomains= domainsrcfg.Routesis never set (returns early)- Result: OS gets match domains with no nameservers, resolver gets no routes
The fix: when
toIPsOnlyreturns empty forsingleResolverSet(), we should fall through to the quad-100 proxy path.Let me also check what happens with non-DoH resolvers in a similar scenario - there might be a second issue:
- Assistant
Now I have a complete understanding of the issue. Let me trace through the
compileConfigflow for app connector routes:cfg.needsOSResolver()= true (has routes)- None of the first 3 switch cases match
cfg.singleResolverSet()returns URL-based resolvers (e.g.,http://100.x.x.x:1234/dns-query)len(singleResolverSet()) > 0= truem.os.SupportsSplitDNS()= true for systemd-resolvedtoIPsOnly(...)returns empty because URLs aren't IP:port 53ocfg.Nameservers = [](empty!)ocfg.MatchDomains = [example.com]- Early return with empty nameservers AND no
rcfg.Routesset
The OS gets told to route domains with no nameserver, and the resolver gets no routes. The fix: when
toIPsOnlyreturns empty forsingleResolverSet(), fall through to the quad-100 proxy path.Let me also check if there's an additional issue - when there are only split DNS routes with no default resolvers and no MagicDNS:
- Assistant
Now I have a complete understanding. Let me implement the fix. The issue is in
compileConfigat thesingleResolverSet()check. When resolvers are non-IP (like app connector DoH URLs),toIPsOnlyreturns empty, but we still return early with broken config. - Assistant
Now I can see the exact issue. The problem is at line 370-376: when
toIPsOnly(cfg.singleResolverSet())returns empty (because resolvers are URLs, not IP:port), the code still returns early with empty nameservers but populated match domains. This means the OS is told to route those domains but has no DNS server to serve them.Let me implement the fix:
- Assistant
Let me use the replace command instead:
- Assistant
Good, the file uses tabs. Let me use the replace command to make the change.
- Assistant
Let me try using sed instead:
- Assistant
Let me open the file and try the edit command from there:
- Assistant
Let me try using the edit command with exact line range.
- Assistant
Now let me verify the edit was applied correctly:
- Assistant
Good, the edit looks correct. Now let me run the existing tests to make sure nothing is broken.
- Assistant
The go module cache is not found. Let me check how to set up the environment properly.
- Assistant
Need to set GOPATH or GOMODCACHE.
- Assistant
Let me try setting GOPATH and running the test.
- Assistant
Need to set HOME too.
- Assistant
Let me see if the tests pass:
- Assistant
All existing tests pass. Now let me run the full test suite for the dns package to make sure nothing else is broken.
- Assistant
Let me also run the tests in the ipn/ipnlocal package since that's where the DNS config for netmap is built:
- Assistant
Now let me write a test to reproduce the issue scenario. Let me look at how existing test cases are structured:
- Assistant
Now I need to add a test case for the app connector scenario. Let me look at the test structure to add a test that verifies the fix:
- Assistant
Now let me look at the test right after the
routes-splitcase to find a good place to add the new test: - Assistant
Now I need to add a test case that covers the app connector scenario. Let me add it after the
routes-splittest case. - Assistant
Now I need to add a test case for the app connector scenario. Let me add it after the
routes-splittest case. The test should verify that when we have a single resolver set with non-IP resolvers (like DoH URLs), we fall through to the quad-100 proxy path instead of trying to set empty nameservers on the OS. - Assistant
Wait, that was placed in the wrong file - it seems the test case was inserted into manager.go instead of manager_test.go! Let me check and fix this.
- Assistant
I made a mistake - the test code was inserted into
manager.goinstead ofmanager_test.go. Let me revert the manager.go changes and redo them properly. - Assistant
Good. Now let me redo the fix in manager.go properly:
- Assistant
Now let me apply the edit to the manager.go file:
- Assistant
Good, the fix is applied correctly. Now let me add the test case to the test file. Let me open the test file and find the right location.
- Assistant
Now let me add the test case right after the
routes-splitcase. I'll add it between lines 452 and 453: - Assistant
Now let me run the tests to make sure the new test passes:
- Assistant
The new test passes. Now let me run the full test suite to make sure everything is working.
- Assistant
Let me also run the ipn/ipnlocal tests to make sure nothing is broken there.
- Assistant
Let me now review the full diff to make sure everything looks good.
- Assistant
The diff looks clean. Let me also check if there are any other tests in the repository that might be affected by this change.
- Assistant
Let me also run the ipn/ipnlocal tests:
- Assistant
All tests pass. Let me now run a broader set of tests to be extra sure:
- Assistant
Good, no vet errors. Let me now review the complete fix one more time to make sure it's correct.
- Assistant
Let me also verify the fix handles the scenario from the issue description by looking at what happens in the
dnsConfigForNetmapflow for the described scenario. Let me check what happens when MagicDNS is off and there are only app connector routes. - Assistant
Let me now also check the other part of the issue - when there are only app connector routes and no default resolvers, the code in
dnsConfigForNetmapcorrectly doesn't add any fallback resolvers, which is the desired behavior. Let me verify this by looking at the end ofdnsConfigForNetmap: - Assistant
Good. The
dnsConfigForNetmapfunction correctly handles the described scenario. When there are app connector routes but no default resolvers and no exit node, none of the switch cases match, so no fallback resolvers are added. This is correct.Let me run the full test suite one more time to make sure everything is good.
- Assistant
Let me check the full test output for the new test case:
- Assistant
All tests pass, including the new test case. Let me now finalize and submit the changes.
Let me do a final review of the changes:
- Assistant
Now let me provide the checklist and submit:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.