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
Let me understand the issue:
- The issue is about split DNS not being registered with the OS when using an app connector.
- Specifically on Linux with systemd-resolved.
- When MagicDNS is turned off and there's no global DNS fallback, Tailscale doesn't register split DNS with the OS.
Let me explore the repository structure to understand how DNS registration works, particularly for systemd-resolved and app connectors.
Let me start by exploring the repository.
Assistant
Let me search for relevant files related to DNS management and systemd-resolved.
Assistant
I need to make a single tool call. Let me search for all these things in one command.
Assistant
Let me look for the DNS manager code and how split DNS is handled:
Assistant
There's no net/dns directory. Let me look for the DNS manager. It might be in the wgengine or internal directories.
Assistant
Found
./net/dns. Let me explore that directoryAssistant
Let me look at the key DNS files. First, let me understand how the DNS manager works:
Assistant
Let me see the full
compileConfigmethodAssistant
Let me just continue reading the file with cat.
Assistant
Let me continue reading
Assistant
Let me look at
config.goto understand the Config struct and methods likeneedsOSResolver,hasDefaultResolvers, etcAssistant
Let me understand how app connector routes are set up. Let me look at the app connector code
Assistant
Let me look at the appc directory
Assistant
Let me look at where the DNS config is built with routes for app connectors.
Assistant
Let me look at the key file where DNS config routes are set up:
Assistant
Let me read more from this file
Assistant
Let me understand the CorpDNS setting
Assistant
Let me look at the broader function that builds the DNS
Assistant
Let me see the full
dnsConfigForNetmapfunctionAssistant
Let me check how nm.DNS.Routes is populated - this contains split DNS routes
Assistant
Let me look at the full context of the
dnsConfigForNetmapfunction, specifically the early return when CorpDNS is falseAssistant
Let me look at the appc package to understand what
PickSplitDNSPeersdoesAssistant
Let me look at the
PickSplitDNSPeersfunction:Assistant
Let me search more broadly
Assistant
Now let me look at the conn25.go file to understand what it does.
Assistant
Let me see the full dnsConfigForNetmap function from start to end
Assistant
Now I understand the issue. Let me trace through the logic:
- In
dnsConfigForNetmap(line 964), whenCorpDNS()is false, it returns early - This means split DNS routes from
nm.DNS.Routesand app connector routes (conn25) are never added to thedcfg - In
compileConfig,needsOSResolver()checks for default resolvers OR routes - both are empty - So no OS DNS configuration is applied
The fix should ensure that split DNS routes are still added even when MagicDNS is off. Let me look at what the early return skips and determine the minimal change
- In
Assistant
Let me check how
AcceptDNSis used in the resolverAssistant
Let me search in the resolver package for Accept
Assistant
Let me look at how acceptDNS is used in the forwarder to understand if it affects routing:
Assistant
Now let me see line 1326 and 1352:
Assistant
Let me look at how setRoutes works and how routes are configured:
Assistant
Let me check if the resolver will still answer queries when AcceptDNS is
Assistant
Now I have a clear understanding of the issue. Let me implement the fix.
The problem is in
dnsConfigForNetmap: whenCorpDNS()is false (MagicDNS off), it returns early before adding split DNS routes from the control plane and app connector. This means no split DNS is registered with the OS.The fix: Move the CorpDNS check so that split DNS routes are always added, while MagicDNS-specific configuration (search domains, MagicDNS root domains, default resolvers, fallback resolvers) is still conditional on Corp
Assistant
Now let me open the file and make the edit. Let me first see the exact lines:
Assistant
Let me see the rest of the fallback section
Assistant
Let me see the full fallback section:
Assistant
Now I'm ready to implement the fix. The change needs to restructure
dnsConfigForNetmapso that split DNS routes are always added, while MagicDNS-specific settings are conditional onCorpDNS().Let me make the edit
Assistant
Let me see the current state of the file around the area I edited:
Assistant
Let me revert my changes and make a cleaner edit. Let me first see the git diff to understand what I changed
Assistant
Let me revert the changes first
Assistant
Let me verify my understanding by looking at
compileConfigmore carefully for the native split DNS pathAssistant
Now I have a clear picture. I need two changes:
dnsConfigForNetmap: Add split DNS routes even when CorpDNS is falsecompileConfig: Don't use native split DNS iftoIPsOnlyreturns empty (because DoH URLs can't be used by the OS directly)
Let me first fix `dnsConfigForNet
Assistant
Let me make the edits step by step. First, let me open the file
Assistant
The
opencommand doesn't support--file. Let me use it without that option. But the current file is already set to node_backend.go, so I can just useopen.Assistant
Now I'll make the edits. Let me replace the block from the CorpDNS check through the end of the function
Assistant
Let me verify the rest of the file:
Assistant
There's a duplicate return. Let me fix that
Assistant
The file is 1085 lines. Let me see lines 1080-1085:
Assistant
I need to remove the duplicate
return dcfgand closing brace. Let me fix:Assistant
The file looks good. Let me verify with git diff
Assistant
Good. Now let me also fix the
compileConfigfunction to handle DoH-only resolvers. Let me look at the relevant section againAssistant
Now I need to protect the native split DNS path in manager.go from setting empty nameservers when all resolvers are DoH URLs. Let me edit
Assistant
I see an extra closing brace on line 380. Let me fix that
Assistant
Good. Let me verify the manager.go diff
Assistant
Both edits look correct. Let me try to build the code to verify there are no syntax errors
Assistant
Let me check if go is available
Assistant
Go is available. Let me set up GOPATH and try building
Assistant
Let me also build the dns package
Assistant
Let me set up GOCACHE and try again
Assistant
The DNS package builds. Let me also build the ipnlocal package
Assistant
Good, both packages build successfully. Let me run the relevant tests to make sure nothing is broken
Assistant
All DNS tests pass. Let me also run the ipnlocal tests
Assistant
All tests pass. Let me also check if there are specific tests for
dnsConfigForNetmapandcompileConfigthat test the CorpDNS behaviorAssistant
Let me check the DNS config tests
Assistant
Let me also look at the local_test.go tests for dnsConfigForNet
Assistant
Let me look at the test case with CorpDNS: false at line 3922
Assistant
Let me search for tests with CorpDNS: false and dnsConfigForNetmap
Assistant
Let me verify both diffs one more time
Assistant
The diffs look correct. Let me also run the appc tests to make sure nothing is broken
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.