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 start by exploring the repository structure to understand how the codebase is organized and find the relevant code for handling split DNS configuration.
Assistant
Let me understand the issue better. The issue is about "split dns" not being registered with the OS when using an app connector. Let me search for files related to DNS configuration and app connectors.
<tool_call> <function=bash_terminal> <parameter=command> find . -type f -name "*.go" | xargs grep -l "split.*dns|splitdns" 2>/dev/null | head -20 </tool_call>
Assistant
Let me run the search command properly.
Assistant
Now let me look at the relevant files, starting with the app connector code since the issue mentions app connectors.
<tool_call> <function=bash_terminal> <parameter=command> ls -la appc/ </tool_call>
Assistant
I need to run the bash_terminal command properly to execute the list command.
Assistant
Let me look at the app connector file to understand how split DNS routes are set up with app connectors.
Assistant
Now let me look at the node_backend.go file which uses this PickSplitDNSPeers function:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "addSplitDNSRoutes|PickSplitDNSPeers|SplitDNS" ipn/ipnlocal/node_backend.go </tool_call>
Assistant
I need to run the bash_terminal command properly to search for the relevant code in node_backend.go.
Assistant
Let me look at the full context around line 985-1050 in node_backend.go to understand how split DNS routes are being added:
Assistant
Let me continue reading to see the rest of the function and understand when split DNS routes are not being added:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1060,1120p' ipn/ipnlocal/node_backend.go </tool_call>
Assistant
Let me try running the grep and sed commands again - I notice the command is being executed correctly. Let me continue viewing the file.
Assistant
Now I can see the issue more clearly. Let me look at the complete function and the control knobs to understand the full context:
Assistant
Now I understand the issue better. Let me look at the function signature and where
corpDnsis used. The issue states:- Linux w/ systemd-resolved
- Turn off MagicDNS
- No global dns fallback
- results in Tailscale not being used for DNS by the operating system
Looking at the code, I can see:
- The function returns early if
!prefs.CorpDNS()- this means if CorpDNS is disabled, it won't add any routes including split DNS routes - The split DNS routes for app connectors (conn25) are added via
addSplitDNSRoutes(m)but only ifconn25DNSTargetsis not nil andmis not nil
Let me check the
corpDns()preference:<tool_call> <function=bash_terminal> <parameter=command> grep -rn "func.CorpDNS" --include=".go" . | head -10 </tool_call>
Assistant
Let me run the bash command to search for the CorpDNS function.
Assistant
Now let me look at the issue more carefully. The issue mentions:
- Linux w/ systemd-resolved
- Turn off MagicDNS
- No global dns fallback
- results in Tailscale not being used for DNS by the operating system
Looking at the code flow:
- If
!prefs.CorpDNS()returns early - no split DNS routes are added - Even with CorpDNS enabled, there's an early return if using exit node with DoH proxy:
if buildfeatures.HasUseExitNode { if dohURL, ok := exitNodeCanProxyDNS(nm, peers, prefs.ExitNodeID()); ok { ... addSplitDNSRoutes(useWithExitNodeRoutes(nm.DNS.Routes)) return dcfg // <-- Here it returns early, before adding app connector split DNS routes! } }But wait, looking at the code again, the exit node early return only returns if it can proxy DNS. Let me look at what
useWithExitNodeRoutesreturns - it might filter out the app connector routes.Assistant
Now let me look at the
useWithExitNodeRoutesfunction:Assistant
Let me now look at what happens when there's an exit node that can proxy DNS. The issue is that the code returns early at line 1024 (the
return dcfgstatement), which means it never reaches the code that adds the app connector split DNS routes.Looking at lines 1007-1024:
if buildfeatures.HasUseExitNode { if dohURL, ok := exitNodeCanProxyDNS(nm, peers, prefs.ExitNodeID()); ok { filtered := useWithExitNodeResolvers(nm.DNS.Resolvers) if len(filtered) > 0 { addDefault(filtered) } else { // If no default global resolvers with the override // are configured, configure the exit node's resolver. addDefault([]*dnstype.Resolver{{Addr: dohURL}}) } addSplitDNSRoutes(useWithExitNodeRoutes(nm.DNS.Routes)) return dcfg // <-- Early return here! } }The problem is that when using an exit node that can proxy DNS, the code returns early and never executes the code that adds app connector split DNS routes (lines 1035-1050).
Now let me check the
controlknobs.gofile for theDisableSplitDNSWhenNoCustomResolversknob:<tool_call> <function=bash_terminal> <parameter=command> cat control/controlknobs/controlknobs.go </tool_call>
Assistant
Let me try running the cat command for the controlknobs.go file.
Assistant
Let me search for where
DisableSplitDNSWhenNoCustomResolversis used:<tool_call> <function=bash_terminal> <parameter=command> grep -rn "DisableSplitDNSWhenNoCustomResolvers" --include="*.go" . | head -20 </tool_call>
Assistant
Let me run the grep command to find where DisableSplitDNSWhenNoCustomResolvers is used.
Assistant
Let me look at the manager.go file to see how DisableSplitDNSWhenNoCustomResolvers is used:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "DisableSplitDNSWhenNoCustomResolvers" net/dns/manager.go -A 5 -B 5 </tool_call>
Assistant
I need to run the grep command to look at how DisableSplitDNSWhenNoCustomResolvers is used in manager.go.
Assistant
Let me understand the issue better by looking at the entire flow. Let me find where the DNS configuration is applied to the OS:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "ApplyConfig|SetDNS|setDNS" ipn/ipnlocal/node_backend.go | head -20 </tool_call>
Assistant
Let me run the grep command to find where DNS configuration is applied to the OS.
Assistant
Let me search for where the DNS configuration is applied in the codebase, looking for files that call the ApplyConfig or similar functions:
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "ApplyConfig" --include="*.go" ipn/ipnlocal/ | head -10 </tool_call>
Assistant
It seems the grep command didn't return any output. Let me try a different approach to find where the DNS configuration is applied.
Assistant
The grep command is not returning any output. Let me try to search for DNS-related functions in the local package.
Assistant
Let me look at the local.go file where dnsConfigForNetmap is called to understand how the DNS configuration is applied:
Assistant
Now I see the issue. The
dcfgis passed tob.e.Reconfig(cfg, rcfg, dcfg). The issue is that when an exit node can proxy DNS, the code returns early fromdnsConfigForNetmapat line 1024, which means the app connector split DNS routes are never added.Let me look at the exact code flow again to understand the issue better. The issue description says:
- Linux w/ systemd-resolved
- Turn off MagicDNS
- No global dns fallback
- results in Tailscale not being used for DNS by the operating system
Looking at the code in
dnsConfigForNetmap, there's a potential issue at line 1019:// Add split DNS routes, with no regard to exit node configuration. addSplitDNSRoutes(nm.DNS.Routes)And then lines 1035-1050:
// Add split DNS routes for conn25 conn25DNSTargets := appc.PickSplitDNSPeers(nm.HasCap, nm.SelfNode, peers, prefs.AppConnector().Advertise) if conn25DNSTargets != nil { ... }But there's an early return at line 1024 that happens when using an exit node that can proxy DNS. Let me verify this is the issue by examining the exact code:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '997,1060p' ipn/ipnlocal/node_backend.go </tool_call>
Assistant
Let me view the code around line 997-1060 to understand the early return issue when using an exit node.
Assistant
Now I can clearly see the issue. When using an exit node that can proxy DNS (DoH), the code returns early at line 1017 (
return dcfg) before adding the app connector split DNS routes (lines 1035-1050).The fix should be to add the app connector split DNS routes even when using an exit node that can proxy DNS. Let me also check the
useWithExitNodeRoutesfunction to see if it filters out app connector routes.The issue is:
- When an exit node can proxy DNS, the code returns early at line 1017
- This prevents the app connector split DNS routes from being added (lines 1035-1050)
- The app connector split DNS routes are needed to route DNS requests to the app connector
Let me also look at the
useWithExitNodeRoutesfunction to see if it filters out certain routes:<tool_call> <function=bash_terminal> <parameter=command> sed -n '823,846p' ipn/ipnlocal/node_backend.go </tool_call>
Assistant
Let me view the useWithExitNodeRoutes function to understand how it filters routes.
Assistant
Now I understand the issue fully. The problem is:
- When using an exit node that can proxy DNS (DoH), the code returns early at line 1017 (
return dcfg) - This prevents the app connector split DNS routes from being added (lines 1035-1050)
- The
useWithExitNodeRoutesfunction at line 1015 filters out routes, but it only filters based on theUseWithExitNodeflag on the resolvers, not on the route itself
The fix should be to:
- Not return early from the exit node DNS proxy path
- Continue to add the app connector split DNS routes even when using an exit node that can proxy DNS
Let me look at the exact lines again and prepare a fix:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1000,1060p' ipn/ipnlocal/node_backend.go </tool_call>
- When using an exit node that can proxy DNS (DoH), the code returns early at line 1017 (
Assistant
I need to continue reading the code to understand the full flow. Let me try again with a different sed range.
Assistant
Now I understand the issue clearly. The problem is that when an exit node can proxy DNS (DoH), the code returns early at line 1017 (
return dcfg) and never reaches the app connector split DNS routes code (lines 1035-1050).The fix should be to:
- Remove the early return after adding exit node split DNS routes
- Continue to add the app connector split DNS routes
However, I need to be careful about how the
useWithExitNodeRoutesfunction handles the routes - it filters out routes that don't have resolvers withUseWithExitNodeset. This means the regular routes might be filtered out.Looking at the code again:
- Line 1015:
addSplitDNSRoutes(useWithExitNodeRoutes(nm.DNS.Routes))- adds filtered routes - Line 1033:
addSplitDNSRoutes(nm.DNS.Routes)- adds all routes (no filtering) - Lines 1035-1050: adds app connector routes
The fix should be to remove the early return at line 1017 and let the code continue to add the app connector routes. But we need to be careful about the filtering - when using an exit node, we should still add the app connector routes.
Assistant
Let me try running the sed command with a slightly different approach to see the code that needs to be fixed.
Assistant
Now I can see the issue. The fix should remove the
return dcfgline at line 1017 and also ensure that app connector split DNS routes are added when using an exit node.Let me look at what the app connector split DNS routes code looks like to understand how to integrate it properly:
<tool_call> <function=bash_terminal> <parameter=command> head -n 1055 ipn/ipnlocal/node_backend.go | tail -n 20 </tool_call>
Assistant
I need to get the context around the app connector split DNS routes code.
Assistant
Now I understand the issue. The fix should:
- Add the app connector split DNS routes even when using an exit node that can proxy DNS
- Remove the early return or move the app connector routes addition before the return
Let me look at the full function to understand the structure better:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "func dnsConfigForNetmap" ipn/ipnlocal/node_backend.go </tool_call>
Assistant
Let me run the grep command to find the function definition.
Assistant
Now let me look at the test file to understand the expected behavior better:
Assistant
Let me look at the conn25-split-dns test case to understand the expected behavior:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '393,470p' ipn/ipnlocal/dnsconfig_test.go </tool_call>
Assistant
Let me try running the sed command to view the test case for conn25-split-dns.
Assistant
Now I understand the test case. The expected behavior is that when an app connector is set up, the DNS routes should include the app connector's DNS resolver for the domains specified.
Let me now create a fix. The issue is that when using an exit node that can proxy DNS (DoH), the code returns early before adding the app connector split DNS routes.
The fix should be to:
- Add the app connector split DNS routes even when using an exit node that can proxy DNS
- Remove or modify the early return
Let me look at the exact lines that need to be modified:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1000,1060p' ipn/ipnlocal/node_backend.go </tool_call>
Assistant
Let me view the file directly using the open command:
Assistant
Now I can see the issue. The code at line 1017 returns early after adding exit node split DNS routes, which prevents the app connector split DNS routes from being added (which happens at lines 1035-1050).
The fix should be to:
- Add the app connector split DNS routes before the early return when using an exit node with DoH
- Or remove the early return and let the code continue to the normal flow
Looking at the code, I think the best fix is to add the app connector split DNS routes before the early return, since the exit node DoH configuration should still respect the app connector DNS routes.
Let me prepare the fix:
<tool_call> <function=bash_terminal> <parameter=command> head -n 1025 ipn/ipnlocal/node_backend.go | tail -n 10 </tool_call>
Assistant
Let me try to view the exact lines around the issue to prepare the fix.
Assistant
Now I can see the issue. The fix should be to add the app connector split DNS routes before the early return. Let me prepare the fix using the edit command:
The current code structure is:
if buildfeatures.HasUseExitNode { if dohURL, ok := exitNodeCanProxyDNS(nm, peers, prefs.ExitNodeID()); ok { ... addSplitDNSRoutes(useWithExitNodeRoutes(nm.DNS.Routes)) return dcfg // <-- This is the problem } } // ... later code that adds app connector routes conn25DNSTargets := appc.PickSplitDNSPeers(...)The fix should be to add the app connector routes before the return statement. Let me create the fix:
<tool_call> <function=bash_terminal> <parameter=command> cat ipn/ipnlocal/node_backend.go | head -n 1025 | tail -n 5 </tool_call>
Assistant
Let me try the bash_terminal command properly to get the content around line 1025.
Assistant
The file has 1080 lines. Let me view the exact content around the problematic lines:
<tool_call> <function=bash_terminal> <parameter=command> cat ipn/ipnlocal/node_backend.go | sed -n '1003,1025p' </tool_call>
Assistant
Let me try a different approach to view the file content around the issue.
Assistant
<tool_call> <function=bash_terminal> <parameter=command> awk 'NR>=1027 && NR<=1055' ipn/ipnlocal/node_backend.go </tool_call>
Assistant
I notice the terminal command is not being executed properly. Let me try a simpler command first to verify the terminal is working.
Assistant
Now I have a clear picture of the issue. The problem is that when using an exit node that can proxy DNS (DoH), the code returns early at line 1017, which prevents the app connector split DNS routes from being added (lines 1035-1050).
The fix should be to add the app connector split DNS routes before the early return when using an exit node with DoH. Let me apply the fix:
Assistant
Let me open the file first and then apply the fix.
Assistant
Now I can see the file is open. Let me navigate to the exact lines that need to be fixed. First, let me scroll down to see the code around lines 1003-1025:
Assistant
Now I can see the exact issue. Lines 1015-1016 show the early return that prevents app connector split DNS routes from being added. The fix should add the app connector split DNS routes before the return statement.
Assistant
The fix has been applied. Now I notice that the code is duplicated - the app connector split DNS routes code is now in both the exit node path (lines 1017-1034) and the normal path (lines 1053-1070). This is not ideal, but it will work. However, it would be cleaner to refactor the code to avoid duplication.
Let me check if the fix compiles correctly by running go build:
<tool_call> <function=bash_terminal> <parameter=command> cd /tailscale && go build ./ipn/ipnlocal/... 2>&1 | head -30 </tool_call>
Assistant
Let me try to compile the code to check for errors.
Assistant
The go module cache is not set up. Let me set the GOMODCACHE and try again.
Assistant
Let me try setting up the environment properly:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=/root/go/pkg/mod && export GOCACHE=/tmp/go-cache && export HOME=/root && cd /tailscale && go build ./ipn/ipnlocal/... 2>&1 | head -30 </tool_call>
Assistant
Let me try running the build command properly:
Assistant
The build succeeded! Now let me run the existing tests to make sure the fix doesn't break anything:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=/root/go/pkg/mod && export GOCACHE=/tmp/go-cache && export HOME=/root && cd /tailscale && go test ./ipn/ipnlocal/... -run TestDNSConfig -v 2>&1 | head -100 </tool_call>
Assistant
Let me run the test command properly:
Assistant
Assistant
The test command didn't run properly. Let me try running it again.
Assistant
Assistant
Let me view the current state of the code to understand what needs to be refactored:
Assistant
Assistant
Let me run the build command properly.
Assistant
Assistant
Let me run the tests properly to verify the fix works correctly.
Assistant
Assistant
The terminal command is not being executed properly. Let me try a different approach to run the app connector tests.
Assistant
Assistant
Let me run the DNS tests to verify the fix doesn't break anything.
Assistant
Assistant
Let me check the current state of the changes I made to the file.
Assistant
Assistant
Let me review the changes I made:
Assistant
Assistant
The command is not being executed properly. Let me try again.
Assistant
Assistant
Let me run the tests to verify the fix is correct.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.