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 start by understanding the repository structure and the issue. The issue is about split DNS not being registered with the OS when using an app connector. Let me explore the codebase to understand how DNS and app connectors work.
The issue description says:
- 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.
Let me explore the repository structure first.
Assistant
Let me explore the relevant areas. I'll look at the app connector code and DNS management
Assistant
Let me do one command at a time.
Assistant
Let me look at the app connector code to understand how it works with DNS.
Assistant
Let me look at the key areas:
Assistant
Let me look at the critical code paths:
Assistant
Now let me look at the DNS manager logic
Assistant
Let me understand more about
matchDomains()andsingleResolverSet():Assistant
Let me see those functions:
Assistant
Let me look at the rest of the switch statement and the fallback handling
Assistant
Let me look at
needsOSResolverand the initial config checksAssistant
Let me look at these functions:
Assistant
Let me look at the app connector's PickSplitDNSPeers
Assistant
Let me look at the DNS manager's main config
Assistant
Let me look at the
Setfunction and how the config is compiledAssistant
Let me look at the beginning of
dnsConfigForNetmapAssistant
Let me look at the full
dnsConfigForNetmapfunctionAssistant
Let me look at how systemd-resolved's DNS manager handles the config
Assistant
Let me look at the full
compileConfigfunction:Assistant
Now I have a good understanding. Let me look at the
singleResolverSetfunction and the condition at line 370 more carefully. The issue seems to be that when all split DNS routes have the same resolver (a DoH URL like from app connector), the code tries to pass them directly to the OS buttoIPsOnlyreturns empty because DoH URLs can't be parsed as IP:port.Let me also check how
toIPsOnlyworks and what happens:Assistant
Let me look at the dnstype package to understand Resolver.IPPort().
Assistant
Let me look at the Resolver type and its IPPort function
Assistant
Now I understand the bug. Let me look at the test file to understand existing test cases and verify my theory
Assistant
Let me look at the manager test file for relevant test patterns
Assistant
Let me look at the relevant test case around line 832
Assistant
Let me now look at
serviceIPsto understand what nameservers are set in the fallback pathAssistant
Let me see the serviceIPs function.
Assistant
Now I have a clear understanding of the bug. Let me verify my theory by looking at the exact code that needs to be changed:
Assistant
Let me just use the open command correctly.
Assistant
Now I can see the issue clearly. On line 370, when all split DNS routes go to the same resolver (which happens with app connectors), the code tries to pass those resolvers directly to the OS via
toIPsOnly. But app connector resolvers are DoH URLs (likehttp://100.x.y.z/dns-query), whichtoIPsOnlycannot parse, resulting in empty nameservers being sent to the OS. The OS then has no DNS servers to use for the split DNS domains.The fix is to check that
toIPsOnlycan actually extract IPs from the single resolver set before taking this shortcut. Let me apply the fix:Assistant
Let me use the replace command instead
Assistant
Good, the change is applied. Now let me run the tests to make sure nothing breaks:
Assistant
Let me check the Go environment:
Assistant
Let me set up the Go environment and run the
Assistant
Let me set up the Go cache and try again.
Assistant
All DNS manager tests pass. Let me also run the DNS config tests and the app connector tests
Assistant
All DNS tests pass. Let me also run the app connector tests and ipnlocal DNS
Assistant
Let me also run the DNS config test in ipn/ipn
Assistant
All tests pass including the conn25-split-dns tests. Let me verify the final state of my change:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.