Skip to content

MagicDNS/DNS resolution broken after unclean shutdown #19062

Open

Description

@shasderias

What is the issue?

On a Linux system with a specific DNS setup, if tailscaled is terminated without being given a chance to cleanup, DNS breaks.

This specific setup is:

  • no systemd-resolved configured
  • /usr/sbin/resolvconf exists as a symlink to resolvectl
  • no global nameservers configured for the Tailnet
  • /etc/resolv.conf is a regular file (i.e not a symlink)

This is the out-of-the-box configuration for an exe.dev VM. The VM image is based off Ubuntu 24.04.4 LTS (kernel 6.12.67).

I can reproduce on Tailscale versions 1.94.2 and 1.96.2.

Root Cause

After an unclean shutdown (crash, SIGKILL, power loss), tailscaled misdetects the system's DNS manager.

  1. The unclean shutdown skips ExecStopPost=/usr/sbin/tailscaled --cleanup, so the Tailscale-written /etc/resolv.conf persists. This file contains a comment with the phrase resolvconf-overwrite.
  2. On restart, resolvOwner() sees resolvconf-overwrite in the stale /etc/resolv.conf and incorrectly returns resolvconf.
  3. resolvconfStyle() finds /usr/sbin/resolvconf (a symlink to resolvectl on Ubuntu 24.04), doesn't recognize it as Debian resolvconf, and returns openresolv.
  4. The openresolv manager calls resolvconf -i, which fails because /usr/sbin/resolvconf is actually resolvectl (via symlink), which does not support openresolv's -i flag.
  5. This prevents Tailscale's DNS resolver from starting correctly. DNS resolution breaks entirely.

Graceful shutdowns are unaffected because --cleanup restores the original /etc/resolv.conf from backup, allowing Tailscale's DNS resolver to start correctly.

Steps to reproduce

Reproduced on a clean exe.dev VM.

# Install Tailscale and authenticate
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up --auth-key=<YOUR_AUTH_KEY>

# Verify DNS works
dig google.com @100.100.100.100 +short +timeout=3
ping google.com

# Simulate unclean shutdown
sudo kill -9 $(pidof tailscaled)

# Restart tailscaled (simulates system recovery after crash/power loss)
sudo systemctl start tailscaled

# Verify that DNS is now broken
dig google.com @100.100.100.100 +short +timeout=5
ping -c 1 -W 3 google.com

# Confirm buggy DNS management detection in logs
sudo journalctl -u tailscaled --since "5 min ago" --no-pager | grep "rc="
# on my system, prints something like rc=resolvconf resolvconf=openresolv ret=openresolv

Are there any recent changes that introduced the issue?

No response

OS

Linux

OS version

exe.dev's customized Ubuntu 24.04.4 image

Tailscale version

1.94.2, 1.96.2

Other software

No response

Bug report

BUG-83fbf900f22405afb9f4178bb7a66859771c46b6627255d1e3cd201f707e3ef9-20260320172407Z-3b83535918838606

Activity

  1. changed the title [-]DNS broken after unclean shutdown[/-] [+]DNS resolution broken after unclean shutdown[/+] on Mar 20, 2026
  2. changed the title [-]DNS resolution broken after unclean shutdown[/-] [+]MagicDNS/DNS resolution broken after unclean shutdown[/+] on Mar 20, 2026
  3. added theissue type on Mar 23, 2026
  4. dwroblewski commented on May 20, 2026

    @dwroblewski

    Hitting this on Debian 12 / GCE / tailscale 1.96.4 with a much more common
    repro than kill -9: a routine cloud-console Stop is enough. We hit it the
    first time we stopped the VM to resize the boot disk.

    Environment

    • Debian 12 bookworm, kernel 6.1.0-48-cloud-amd64
    • GCE, image family debian-12
    • Tailscale 1.96.4
    • systemd-resolved 252.39-1~deb12u2, no NetworkManager
    • /sbin/resolvconf and /usr/sbin/resolvconf are both symlinks to
      /usr/bin/resolvectl, shipped by the systemd-resolved package itself on
      bookworm
    • /etc/resolv.conf was a regular file containing tailscale's
      resolvconf-overwrite marker from the previous boot

    Misdetection chain matches your analysis exactly:

    tailscaled: dns: [resolved-ping=yes rc=resolvconf resolvconf=openresolv ret=openresolv]
    tailscaled: dns: using "openresolv" mode
    tailscaled: health(warnable=dns-read-os-config-failed): error: Tailscale failed to fetch the DNS configuration of your device: exit status 1
    tailscaled: dns: resolver: forward: no upstream resolvers set, returning SERVFAIL
    

    exit status 1 comes from the shim rejecting an openresolv flag:

    $ /sbin/resolvconf -i
    /sbin/resolvconf: option requires an argument -- 'i'
    $ echo $?
    1
    

    Why clean shutdown wasn't enough. journalctl -u tailscaled -b -1 | tail
    from the previous boot has no --cleanup lines — the
    ExecStopPost=/usr/sbin/tailscaled --cleanup apparently didn't complete before
    the hypervisor cut power, even though systemd recorded a normal shutdown
    (systemd-logind: Power key pressed short.). The stale marker file survives.

    Fix that worked.

    sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
    sudo systemctl restart tailscaled
    

    Removes the resolvconf-overwrite marker that resolvOwner() keys on, and
    gives resolvconfStyle() the stub-resolv.conf marker it uses to recognize
    the systemd-resolved-stub layout. After restart:

    tailscaled: dns: [resolved-ping=yes rc=resolved resolved=file nm=no resolv-conf-mode=stub ret=systemd-resolved]
    tailscaled: dns: using "systemd-resolved" mode
    tailscaled: dns: using *dns.resolvedManager
    

    End-to-end resolution restored, no health warnings.

    What didn't work.

    • systemctl restart tailscaled alone — stale file still has the marker, same
      misdetection.
    • tailscale set --accept-dns=false — suppresses the symptom but leaves the
      stale file and kills MagicDNS.

    Triage note. Cloud-console Stop is the standard way to perform disk
    resizes, instance-type changes, and reboots-on-stuck-VM on GCE/AWS/Azure. The
    kill -9 repro in the original report surfaces the bug in isolation; this
    path is what users actually hit during routine ops. Re-running --cleanup on
    startup if the marker file is found (or detecting the systemd-resolvconf shim
    by checking whether resolvconf -i accepts the flag) would close this without
    needing user intervention.

  5. M1llenia commented on Aug 26, 2026

    @M1llenia

    I had a similar issue to this that I had to solve. Full disclosure, I'm a complete Github noob and I was using Claude to assist me in troubleshooting my issue + formatting a response below that follows Github etiquette/rules, so please forgive me for any content/formatting mistakes. I will do my best to provide any further information if I can.

    Confirming this on a different environment — Ubuntu 24.04, Pangolin + Traefik stack, Tailscale 1.102.2

    Same log signature as the original report:

    dns: [resolved-ping=yes rc=resolvconf resolvconf=openresolv ret=openresolv]
    dns: using "openresolv" mode
    

    /etc/resolv.conf was a regular file (not a symlink), /usr/sbin/resolvconf symlinked to resolvectl, matching the described trigger conditions.

    I can't confirm the exact unclean shutdown that caused it — I noticed the symptom (SERVFAIL on all non-tailnet DNS) with no corresponding change in my Tailscale admin console or local config, so it's consistent with this happening silently after a restart/reboot I didn't directly observe, exactly as described in the root cause section.

    Downstream impact worth noting: the breakage cascaded well beyond MagicDNS in my case — Traefik couldn't renew Let's Encrypt certs, failed to load its badger middleware plugin at boot (plugin fetch needs DNS), which broke every router including Pangolin's own dashboard, and Newt couldn't fetch its auth token from Pangolin's API. So on a Pangolin-based stack this one bug can take down the entire reverse proxy, not just name resolution.

    Confirmed fix:

    sudo systemctl stop tailscaled
    sudo rm /etc/resolv.conf
    sudo systemctl start tailscaled
    

    Then a restart of the Traefik container to force it to re-fetch its plugins and re-poll Pangolin's config endpoint. I also had to refresh Pangolin's license keys.

    Happy to provide journalctl -u tailscaled output covering the actual break if that's useful for tracking down what triggers the initial misdetection.

  6. samoht9277 commented on Sep 4, 2026

    @samoht9277

    Hitting this on Debian 12 with 1.102.2, with one difference from the original report that I think is worth adding: systemd-resolved is running and reachable here, and it still lands in openresolv mode. The issue text lists "no systemd-resolved" as a precondition, so I almost ruled this out before I looked at the probe line.

    Environment:

    • Debian 12 bookworm, systemd 252.39-1~deb12u2, systemd-resolved active
    • tailscale 1.102.2
    • /sbin/resolvconf and /usr/sbin/resolvconf are both symlinks to /usr/bin/resolvectl
    • neither openresolv nor Debian resolvconf is installed, and there is no /etc/resolvconf or /run/resolvconf
    • no global nameservers on the tailnet, split DNS routes only
    • /etc/resolv.conf was a regular file left over from an earlier tailscaled run

    The trigger was an ordinary reboot. No crash, no kill -9, nothing else on the box changed.

    Straight after boot:

    dns: [resolved-ping=yes rc=resolvconf resolvconf=openresolv ret=openresolv]
    dns: using "openresolv" mode
    dns: resolver: forward: no upstream resolvers set, returning SERVFAIL
    

    Note resolved-ping=yes. resolved answered the ping, but rc=resolvconf short-circuits before that result is ever used.

    What made this slow to diagnose is that the resolver is only half broken. MagicDNS names resolve fine, because tailscaled answers those itself. Every public name gets SERVFAIL. It reads like an upstream DNS outage rather than a local misdetection.

    This matches the chain already described in the issue. The header tailscaled writes into /etc/resolv.conf contains:

    # For more info, see https://tailscale.com/s/resolvconf-overwrite
    

    so the substring search finds "resolvconf" inside tailscale's own comment and concludes that resolvconf owns the file.

    Fix on the same box, no package changes:

    systemctl stop tailscaled
    ln -sfn ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
    systemctl restart systemd-resolved
    systemctl start tailscaled
    
    dns: [resolved-ping=yes rc=resolved resolved=file nm=no resolv-conf-mode=stub ret=systemd-resolved]
    dns: using "systemd-resolved" mode
    

    One gotcha if anyone else applies this. tailscaled has to be stopped before you swap the file. If it is still running it rewrites /etc/resolv.conf back to its own version within a few seconds, so the restart reads that and picks openresolv all over again. I broke a second machine that way before I spotted it.

    Scale here: one machine broke on its own after a reboot. A second reproduced it the moment tailscaled restarted with the plain-file resolv.conf still in place. Four more had the identical shape and I converted them before they got the chance.

  7. raggi commented on Sep 9, 2026

    @raggi
    Member

    It appears exe.dev masks out systemd-resolved:

    skopeo copy docker://ghcr.io/boldsoftware/exeuntu:main-b72307d oci:exeuntu:main-b72307d
    sudo umoci unpack --image exeuntu:main-b72307d /tmp/exebuntu
    sudo ls -la /tmp/exebuntu/rootfs/etc/systemd/system/systemd-resolved.service
    
    lrwxrwxrwx 1 root root 9 Sep  8 17:17 /tmp/exebuntu/rootfs/etc/systemd/system/systemd-resolved.service -> /dev/null
    

    The painful part is this is a misleading way to disable the service, it'd be ideal (selfishly for us) to not leave most of the system looking like resovled should be present.

    Anyway that aside, our handling of the case here needs to improve, we need to recover from unclean shutdown better and we need to improve our detection to better identify a case like this.

  8. NeilJed commented on Oct 20, 2026

    @NeilJed

    Another data point on Amazon Linux 2023. It has the same root cause as described above, and a reboot does not recover it.

    Environment

    • Amazon Linux 2023 (release 2023.12.20261013), aarch64, systemd-resolved 252.23-15
    • Tailscale 1.102.4, default --accept-dns=true
    • /etc/resolv.conf is the AL2023 default, a symlink to /run/systemd/resolve/resolv.conf (not the 127.0.0.53 stub). Tailscale therefore runs in direct mode and replaces it with its own file.
    • /usr/sbin/resolvconf -> ../bin/resolvectl (shipped by systemd-resolved)

    What happened

    tailscaled had run fine in direct mode for about two weeks. During an AWS SSM Patch Manager run, systemd packages were upgraded and systemd-resolved and systemd-networkd were restarted. In the same run the kernel OOM killer killed tailscaled (the host has 916 MB RAM and no swap, and dnf was using about 520 MiB at the time):

    kernel: Out of memory: Killed process 1405 (tailscaled) ...
    systemd[1]: tailscaled.service: Main process exited, code=killed, status=9/KILL
    systemd[1]: tailscaled.service: Failed with result 'oom-kill'.
    

    So this is the unclean-exit case described above. systemd then restarted it through Restart=on-failure (Scheduled restart job, restart counter is at 1). After the restart:

    dns: [resolved-ping=yes rc=resolvconf resolvconf=openresolv ret=openresolv]
    dns: using "openresolv" mode
    health(warnable=dns-read-os-config-failed): error: Tailscale failed to fetch the DNS configuration of your device: exit status 1
    dns: Set: {DefaultResolvers:[] Routes:{...split-DNS routes only...}}
    dns: resolver: forward: no upstream resolvers set, returning SERVFAIL
    

    All non-tailnet lookups failed, including the SSM agent's endpoint, so the instance dropped off SSM until we intervened.

    Notes

    • The chain is the one described in this issue. Tailscale's own header (https://tailscale.com/s/resolvconf-overwrite) makes resolvOwner() return resolvconf. resolvconfStyle() then treats the resolvectl symlink as openresolv, and resolvconf -i/-l exits 1.
    • Rebooting several times did not recover it. The Tailscale-written /etc/resolv.conf stays on disk. The ExecStopPost run of tailscaled --cleanup straight after the kill also logged using "openresolv" mode, so the original resolv.conf (kept as /etc/resolv.pre-tailscale-backup.conf) is never restored.
    • Workaround: tailscale set --accept-dns=false restores DNS, but it turns Tailscale DNS off (as noted earlier in this thread).
    • Recovery that kept split DNS: move the original symlink back (mv -f /etc/resolv.pre-tailscale-backup.conf /etc/resolv.conf) and restart tailscaled. It logged rc=resolved resolved=not-in-use ret=direct and using "direct" mode again, and --accept-dns=true then worked normally.
    • Suggested fix: have resolvOwner() skip a file that ownedByTailscale() recognises (its header contains generated by tailscale), or avoid the substring resolvconf in the header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions