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
Interface
No new interfaces are introduced.
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
Let me analyze the issue. The problem is that when using an app connector with Tailscale on Linux with systemd-resolved, if MagicDNS is turned off and there's no global DNS fallback, Tailscale fails to register split DNS with the OS to route DNS requests to the app connector.
Let me start by exploring the repository structure to understand the codebase.
Assistant
Let me explore the DNS-related code, particularly around systemd-resolved and split DNS.
Assistant
Let me search for files related to DNS management and app connectors more specifically.
Assistant
I need to explore the DNS-related code more carefully. Let me look for DNS management files, especially for systemd-resolved.
Assistant
reasoning followed by thebash_terminal` command.Let me continue exploring the codebase to find the DNS-related code, particularly around systemd-resolved and app connectors.
Assistant
Let me explore the DNS resolver and dns/ folder to understand how DNS settings are handled.
Assistant
The user wants me to explore the DNS-related code in
/tailscale/net/dns. Let me look at the files in that directory to understand how DNS is configured, particularly for systemd-resolved and app connectors.Assistant
Let me continue exploring the DNS-related code, starting with the key files for Linux systemd-resolved and manager.
Assistant
Now let me look at the resolved.go file to understand how DNS configuration is applied to systemd-resolved:
Assistant
Now let me look at the config.go to understand the OSConfig structure:
Assistant
Let me now look at the manager.go to understand how DNS configuration is applied:
Assistant
I have a lot of content now. Let me look at the compileConfig function more closely, which is key to understanding how DNS is configured:
Assistant
Let me see the full compileConfig function:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '293,450p' /tailscale/net/dns/manager.go </tool_call>
Assistant
I need to use the correct command format to read the compileConfig function. Let me use bash_terminal with a proper command.
Assistant
Let me look at how the DNS config is built for app connectors and see how it flows into the DNS manager.
Assistant
Let me continue my investigation. I need to find where the DNS Config is built for app connectors and understand the flow when MagicDNS is turned off.
Assistant
Now let me continue exploring how DNS config is built for app connectors.
Assistant
Let me continue investigating the DNS configuration generation for app connectors.
Assistant
Let me continue exploring to find how the DNS config is generated for app connectors.
Assistant
Let me continue investigating the DNS configuration flow. I need to look at how app connector routes are converted to DNS config.
Assistant
Now let me look at how the DNS config is generated when app connectors are enabled.
Assistant
Now let me search for how DNS config is generated when using app connectors. I need to look for where the DNS config is built and how it incorporates app connector routes.
Assistant
Let me look at the
dnsConfigForNetmapfunction to understand how DNS is configured:Assistant
Let me search for the dnsConfigForNetmap function:
Assistant
Let me continue investigating. The
dnsConfigForNetmapfunction seems to be defined in node_backend.go. Let me look at it:Assistant
Let me look at the full dnsConfigForNetmap function:
Assistant
Now I understand the flow. Let me look at the
PickSplitDNSPeersfunction to understand how app connector DNS routing works:Assistant
I've now analyzed the codebase thoroughly. Let me trace through the issue.
Analysis Summary:
-
Issue: When using an app connector with MagicDNS turned off and no global DNS fallback, Tailscale doesn't register split DNS with systemd-resolved.
-
Root Cause: In
compileConfig(/tailscale/net/dns/manager.go), when all routes use the same resolver (which is the case for app connectors - they all use DoH resolvers likehttp://peer:port/dns-query), the code enters the "let the OS do split DNS" branch:
if len(cfg.singleResolverSet()) > 0 && m.os.SupportsSplitDNS() && !isWindows && !isApple { ocfg.Nameservers = toIPsOnly(cfg.singleResolverSet()) ocfg.MatchDomains = cfg.matchDomains() return rcfg, ocfg, nil }The problem is
toIPsOnly()only extracts IP addresses from resolvers that haveIPPort() && port == 53. DoH URLs from app connectors (http://peer:port/dns-query) don't match this, sotoIPsOnly()returns an , meaning no nameservers are configured!-
Assistant
Now let me look at the exact code section around line 370 to understand the condition better:
Assistant
Now I understand the issue. Let me look at the
hasDefaultIPResolversOnlyfunction to understand how it works:Assistant
Let me read the
hasDefaultIPResolversOnlyfunction:Assistant
Now I understand the issue. Let me trace through what happens:
-
When app connectors are used with MagicDNS turned off and no global DNS fallback, the DNS config has
Routeswith DoH resolvers (e.g.,http://peer:port/dns-query), but noDefaultResolvers. -
In
compileConfig, the code reaches the split DNS section at line 370:if len(cfg.singleResolverSet()) > 0 && m.os.SupportsSplitDNS() && !isWindows && !isApple { ocfg.Nameservers = toIPsOnly(cfg.singleResolverSet()) ... } -
singleResolverSet()returns the resolvers if all routes use the same resolvers. ButtoIPsOnly()only extracts IPs from resolvers that are simple IP:53 - DoH resolvers likehttp://peer:port/dns-queryreturn an empty result. -
This means
ocfg.Nameserversis empty, and no split DNS is registered with systemd-resolved.
The fix: The condition at line 370 should also verify that the single resolver set contains only IP:53 resolvers (similar to
hasDefaultIPResolversOnly()). If the resolvers are DoH URLs, we shouldn't use the "let the OS do split DNS" path because we can't express DoH resolvers directly in the OS config.-
Assistant
Let me continue investigating the tests and the issue.
Assistant
Now I understand the issue clearly. Let me summarize my findings:
Issue Analysis
Root Cause: In
/tailscale/net/dns/manager.go, line 370-374, when app connectors are configured with:- MagicDNS turned off
- No global DNS fallback
The code enters the "let the OS do split DNS" path because
singleResolverSet()returns non-empty (all routes use the same DoH resolver). However,toIPsOnly()then returns an empty slice because DoH URLs (e.g.,http://peer:port/dns-query) don't match the IP:53 format check.Result:
ocfg.Nameserversis empty, so no DNS nameservers are registered with systemd-resolved, breaking DNS resolution for app connector domains.The Fix
The condition at line 370 should also verify that the single resolver set contains only IP:53 resolvers before delegating to the OS. If the resolvers are DoH URLs, we should fall through to the "point at quad-100" branch instead.
I'll add a helper method to Config to check if all route resolvers are IP:53 resolvers, similar to how
hasDefaultIPResolversOnly()works for DefaultResolvers.Assistant
Now I'll implement the fix. I need to add a method to check if all route resolvers are IP:53 resolvers, and use it in the condition at line 370 of manager.go.
Assistant
Now I'll implement the fix. I need to add a helper method and modify the condition in
manager.go.First, let me add a new method to
config.goto check if all route resolvers are IP:53 only:Assistant
Let me continue implementing the fix. I'll add a helper method to check if all route resolvers are IP:53 only, and update the condition in manager.go.
Assistant
Now I need to update the condition in
manager.goto also checkcfg.hasIPResolversOnly():Assistant
Now I need to update the condition in
manager.goto also checkcfg.hasIPResolversOnly():Assistant
I need to use the edit command with the proper format. Let me try again.
Assistant
Let me verify the changes I made:
Assistant
Good, the changes look correct. Now let me verify the fix by running the existing tests:
Assistant
Let me check the Go environment and try to run tests with proper configuration.
Assistant
The user wants me to run the tests to verify my fix. Let me try running the tests with the proper environment variables set.
Assistant
Let me continue watching the test output to see if all tests pass:
Assistant
All tests pass. Let me now verify the fix more thoroughly by examining the test cases related to the scenario described in the issue.
Assistant
Now let me create a test script to verify the fix specifically for the app connector scenario described in the issue:
Assistant
I need to fix the test script to use the correct unexported method name, and also verify the fix works correctly. Let me create a proper test within the dns package:
Assistant
Let me continue with running the test to verify the fix.
Assistant
The user wants me to run the test to verify the fix works correctly. Let me run the test.
Assistant
The test passes! Let me also run all DNS tests to make sure I haven't broken anything:
Assistant
All DNS tests pass. Let me clean up the temporary test file I created for verification (since the checklist says not to add new tests) and run broader tests to ensure nothing is broken.
Assistant
Now let me verify the final state of the changes:
Assistant
The changes look good. Let me run a broader test to ensure I haven't broken anything in the ipnlocal package (which uses DNS configuration):
Assistant
Let me continue verifying the fix by running more comprehensive tests.
Assistant
All tests pass. Let me verify the changes one more time and ensure the fix is complete.
Assistant
My fix is complete and all tests pass. Let me verify the fix one more time by examining the edge cases I should consider:
- App connector with DoH resolver - Fixed: Now falls through to quad-100 path
- Normal split DNS with IP:53 resolvers - Still works: Enters OS split DNS path
- Empty routes - Works:
hasIPResolversOnly()returns true for empty routes - Routes with empty resolver list - Works:
hasIPResolversOnly()returns true for empty resolver lists
Let me also verify there are no regressions in the broader codebase:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.