Skip to content

Tailscale does not observe changes to local DNS resolver while an interface is up #12231

Closed

Description

@varenc

What is the issue?

I have MagicDNS enabled and my machine accepting it with tailscale set --accept-dns=true.

When my local DNS resolver changes, my system apparently does not use it. While the Tailscale VPN is activated (and no traffic is even being routed through it), my system will only use the locally set DNS resolver in place when Tailscale first started. So when I change my DNS resolver this is ignored. I can only observe this indirectly by using another service that reports my DNS resolver to me. The actual resolver being used doesn't appear in scutil --dns, networksetup -getdnsservers Wi-Fi or cat /etc/resolv.conf

My situation: I run dnscrypt-proxy locally with some aggress DNS ad blocking rules and typically have my DNS resolver set to 127.0.0.1. However, when the DNS blocking is too aggressive I have a shortcut that changes my system's DNS resolver to my LAN's resolver. Normally this works fine, however when Tailscale + MagicDNS is enabled changing my local DNS resolver has no affect.

In a very mysterious way Tailscale somehow makes my system keep using the DNS resolver set when Tailscale was started, ignoring all my local DNS settings.

Steps to reproduce

  • Make sure Tailscale is off, MagicDNS is on for your account, and locally has --accept-dns=true.
  • Set my system's DNS resolver to Cloudflare with this: networksetup -setdnsservers Wi-Fi 1.1.1.1
  • Start Tailscale connection: tailscale up
  • Run scutil --dns and observe 1.1.1.1 in my DNS settings.
  • Use the https://my.nextdns.io/ to observe that Cloudflare is my resolver (screenshot)
image
  • Change my local DNS resolve to be Quad9 with this: networksetup -setdnsservers Wi-Fi 9.9.9.9
  • Go back to https://my.nextdns.io/ and observe that Cloudflare is still the resolver!
  • Run scutil --dns and observer than Cloudflare's 1.1.1.1 resolver isn't listed anywhere in my local DNS settings but Tailscale is somehow making my system still use Cloudflare as the resolver.
  • Turn off Tailscale and check DNS server again to observe that it's now using Quad9 as expected.

Also here's some more screenshots of my tailscale settings:
image
image

Are there any recent changes that introduced the issue?

I am a new Tailscale user so I've always observed this behavior.

OS

macOS

OS version

14.3.1

Tailscale version

1.66.4 tailscale commit: 067defc641850791142cc83a44dadae29709344a

Other software

I'm running Little Snitch but all the testing done above was done with Little Snitch off. (however it was still installed on the system, so that might be contributing).

I also ensured that iCloud Private Relay was off (both system wide and the Wi-Fi network specific "Limit IP Address tracking" option).

Bug report

BUG-cafb7d6238f79c6992e84aac8608faa66cc8d12fb844958915c46f6c20dd3592-20240523200412Z-9d50dc0ca9a3f0be

Activity

  1. added
    OS-macos
    on May 24, 2024
  2. changed the title [-]macOS: With MagicDNS enabled Tailscale does not respect changes to my local DNS resolver. Forced to keep using the resolver set when Tailscale first started[/-] [+]Tailscale does not observe changes to local DNS resolver while an interface is up[/+] on May 24, 2024
  3. agottardo commented on May 24, 2024

    @agottardo
    Contributor

    I can reproduce on macOS 14.5. The backend reads the DNS configuration for the default route interface every time the default route interface changes. However, it doesn't observe for changes in real-time. If I attempt to modify the DNS servers specified in Settings.app while my Wi-Fi is up, Tailscale won't pick up the change in resolver until I toggle my Wi-Fi off and on again.

  4. varenc commented on May 24, 2024

    @varenc
    Author

    If it helps, here's my theory of what's happening:

    1. With Tailscale + MagicDNS the macOS VPN configuration declares 100.100.100.100 as a resolver.
    2. For whatever reason, all DNS queries by macOS go now get sent to this resolver. Is this intentional by Tailscale?
    3. The route to 100.100.100.100 is over the Tailscale network interface (not en0), so the traffic is sent there.
    4. When IPNExtension sees plain' ol port 53 DNS queries addressed to 100.100.100.100 it forwards the requests to the resolver specified at time of Tailscale startup.

    And there is the bug I believe.

    A bigger question to me is why macOS needs to send all DNS queries to the Tailscale declared resolver when I only care about it for a very narrow set of things. Ideally only DNS queries already matching the search domain/prefix *.xx-yy.ts.net and *.100.in-addr.arpa would get sent to this resolver. I'm guessing Tailscale has to implement it this way for macOS limitation reasons?

  5. agottardo commented on May 24, 2024

    @agottardo
    Contributor

    100.100.100.100 is the local DNS forwarder inside the Tailscale client.

    As you correctly identified, the issue is that at the moment Tailscale doesn't observe DNS changes. It only reads the DNS server when the VPN goes up and starts using an interface, or when your Mac switches between interfaces (for instance, unplugging your Ethernet cable and switching to Wi-Fi). So we need to build that ability to observe changes and re-configure our DNS forwarder with the new upstream DNS.

    Ideally only DNS queries already matching the search domain/prefix *.xx-yy.ts.net and *.100.in-addr.arpa would get sent to this resolver.

    Yes, we could do split DNS in the case of your very simple setup. But we do need to handle all DNS on the system for more advanced features, such as app connectors. Handling all queries also allows us to do things that the built-in operating system resolvers don't normally do, such as automatic upgrade to DNS over HTTPS when attempting to connect to the most popular public resolvers.

  6. varenc commented on May 24, 2024

    @varenc
    Author

    Thanks for the context! It makes sense given the other features that Tailscale would want to handle DNS exclusively. With this bug fixed I can't think of other drawbacks.

    My workaround for this in the mean time is to keep MagicDNS enabled but turn it off locally with --accept-dns=false. Then I have setup some forwarding rules in my dnscrypt-proxy configuration that forward requests matching my ts.net search domain or .100.in-addr.arpa to the Tailscale 100.^4 resolver. (100.* isn't quite correct, should be 100.64.0.0/10)

  7. barnstar commented on Apr 28, 2025

    @barnstar
    Member

    This issues was resolved in 1.82. DNS configuration changes will now get propagated to Tailscale even while it's running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

OS-macosT5 Usabilitybugdns

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions