Skip to content

Tailscale breaks WSL2 DNS #2815

Closed
Closed

Description

@PieterScheffers

On Windows login, Tailscale is started. When I open Ubuntu 18.04 on WSL2 no DNS is working.

$ dig google.com
; <<>> DiG 9.11.3-1ubuntu1.12-Ubuntu <<>> google.com
;; global options: +cmd
;; connection timed out; no servers could be reached

When opening /etc/wsl.conf, I see Tailscale has added the following snippet:

# added by tailscale
[network]
generateResolvConf = false

When I remove this snippet from /etc/wsl.conf and then terminate and start WSL again, the DNS works again.

C:\WINDOWS\system32> wsl --terminate Ubuntu-18.04
C:\WINDOWS\system32> wsl --distribution Ubuntu-18.04

$ dig google.com
; <<>> DiG 9.11.3-1ubuntu1.12-Ubuntu <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54109
;; flags: qr rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             0       IN      A       142.250.179.206

;; Query time: 21 msec
;; SERVER: 172.29.64.1#53(172.29.64.1)
;; WHEN: Wed Sep 08 09:16:49 CEST 2021
;; MSG SIZE  rcvd: 54

On every restart of Windows the snippet is added to /etc/wsl.conf again.

Activity

  1. DentonGentry commented on Sep 9, 2021

    @DentonGentry
    Contributor

    The write to /etc/wsl.conf was added in 1147c7f to fix #775.

    When first booted with "generateResolvConf = false" present, what is the content of /etc/resolv.conf? I think we'd expect to have written a "nameserver 100.100.100.100" line there.

  2. added
    L2 Few
    OS-windows
    P2 Aggravating
    T5 Usability
    and removed on Sep 9, 2021
  3. PieterScheffers commented on Sep 9, 2021

    @PieterScheffers
    Author

    The /etc/resolv.conf file doesn't exist when the DNS isn't working.

  4. DentonGentry commented on Sep 9, 2021

    @DentonGentry
    Contributor
  5. PieterScheffers commented on Sep 9, 2021

    @PieterScheffers
    Author

    I see MagicDNS is enabled and nameserver 100.100.100.100 is the nameserver. The global nameserver is 1.1.1.1.

  6. DentonGentry commented on Sep 9, 2021

    @DentonGentry
    Contributor

    So we should have written to both /etc/wsl.conf and /etc/resolv.conf, but something went wrong in writing to /etc/resolv.conf and the result is broken DNS.

    Could you send the Tailscale IP address of the Windows host to [email protected], and reference this bug? Maybe we can see what went wrong in telemetry or error it reported.

  7. lorengordon commented on Sep 17, 2021

    @lorengordon

    I'm seeing the same thing in my setup.

  8. rdbisme commented on Sep 23, 2021

    @rdbisme

    Same problem here. MagicDNS enabled, 1.1.1.1 as global nameserver

  9. svercl commented on Sep 24, 2021

    @svercl

    Likewise. I wondered what was causing this, and it turned out to be Tailscale. MagicDNS enabled, and 1.1.1.1 as global nameserver (same as person above me)

    Edit: typo ;)

  10. lorengordon commented on Sep 30, 2021

    @lorengordon

    The upgrade to 1.14.4 re-broke it, by re-adding generateResolvConf = false to /etc/wsl.conf.

  11. 12 remaining items

  12. lorengordon commented on Dec 16, 2021

    @lorengordon

    Hmm, I wonder if the problem is because in wsl2 /etc/resolv.conf is typically a symlink to ../run/resolvconf/resolv.conf? It being a symlink is why I had to modify my original workaround from:

    [ -e /etc/resolv.conf ] || sudo bash -c "echo 'nameserver $(ip route show default | awk '{print $3}')' > /etc/resolv.conf"
    

    to:

    [ -h /etc/resolv.conf -a ! -e /etc/resolv.conf ] && sudo bash -c "rm /etc/resolv.conf; echo 'nameserver $(ip route show default | awk '{print $3}')' > /etc/resolv.conf"
    

    But once I did that, /etc/resolv.conf was no longer a symlink. I bet then the tailscale logic was able to work.

  13. lorengordon commented on Dec 16, 2021

    @lorengordon

    Hysterically, now the backup of the file that tailscale makes is invalid, because wsl2 changes its IP every boot. 🤦‍♂️

  14. voltagex commented on Dec 26, 2021

    @voltagex

    Please allow disabling this - you're breaking WSL2 even when Tailscale isn't connected.

    ping: tailscale.com: Temporary failure in name resolution

  15. voltagex commented on Dec 26, 2021

    @voltagex

    Also, don't change files that aren't yours without asking me first.

  16. evilpilaf commented on Jan 3, 2022

    @evilpilaf

    I was running into the same issue and after updating to tailscale 1.18.2 I was able to remove /etc/wsl.conf and now my DNS is working as expected.

  17. Xalaxis commented on Jan 23, 2022

    @Xalaxis

    I'm unsure what version of Tailscale exactly did it, but this bug has broken networking on all of my WSL2 machines at some point. Deleting the /etc/wsl.conf file seems to fix the issue across Tailscale restarts, so maybe the fix/removal has been added to newer versions?

  18. DentonGentry commented on Jan 23, 2022

    @DentonGentry
    Contributor

    In the 1.20.x release a14d445 means that resolv.conf will only be written if a TS_DEBUG_CONFIGURE_WSL environment variable exists.

  19. arjoh commented on Feb 14, 2022

    @arjoh

    In the 1.20.x release a14d445 means that resolv.conf will only be written if a TS_DEBUG_CONFIGURE_WSL environment variable exists.

    This is currently not working for me. Set TS_DEBUG_CONFIGURE_WSL to True in Windows 11 System environment variables. Tailscale version is 1.20.4.

  20. DentonGentry commented on Mar 27, 2022

    @DentonGentry
    Contributor

    Fixed in 1.20 by #3687

    We may make another attempt to better support WSL in the future. I do not believe this bug will be useful in that, we won't do so until we have something better. Closing this bug.

  21. Rican7 commented on Feb 23, 2024

    @Rican7

    EDIT: Warning the comment below pertains to WSL1. This ticket is titled WSL2. The two stacks are very different.

    I just ran into this myself, and I wanted to report what I ran into (and how I fixed it) in-case it helps future work on WSL compatibility or anyone else that finds this thread.

    Problem

    I had just recently installed Tailscale, and restarted my machine, and then I was running into connectivity (really DNS) issues under WSL (WSL 1, Ubuntu 22.04).

    I checked my /etc/resolv.conf file, as that's a common source of DNS issues in WSL (microsoft/WSL#3438), and saw this:

    $ cat /etc/resolv.conf
    # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
    # [network]
    # generateResolvConf = false
    nameserver fec0:0:0:ffff::1
    nameserver fec0:0:0:ffff::2
    nameserver fec0:0:0:ffff::3
    search tail63fee.ts.net Home
    
    ... which resulted in DNS failing, but I could still ping
    
    $ dig google.com
    ;; communications error to fec0:0:0:ffff::1#53: timed out
    ;; communications error to fec0:0:0:ffff::1#53: timed out
    ;; communications error to fec0:0:0:ffff::1#53: timed out
    ;; communications error to fec0:0:0:ffff::2#53: timed out
    ;; communications error to fec0:0:0:ffff::3#53: timed out
    

    ; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> google.com
    ;; global options: +cmd
    ;; no servers could be reached

    $ ping 8.8.8.8
    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=3.79 ms
    64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=3.50 ms
    64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=3.41 ms
    64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=3.13 ms
    64 bytes from 8.8.8.8: icmp_seq=5 ttl=118 time=3.28 ms
    64 bytes from 8.8.8.8: icmp_seq=6 ttl=118 time=3.52 ms
    64 bytes from 8.8.8.8: icmp_seq=7 ttl=118 time=3.56 ms
    ^C
    --- 8.8.8.8 ping statistics ---
    7 packets transmitted, 7 received, 0% packet loss, time 6005ms
    rtt min/avg/max/mdev = 3.133/3.455/3.791/0.195 ms

    ... Exiting the Tailscale app (in the system tray), removing the resolv.conf (sudo rm /etc/resolv.conf in WSL), and then restarting WSL (wsl --shutdown via an admin/elevated cmd) resulted in this /etc/resolv.conf contents:

    $ cat /etc/resolv.conf
    # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
    # [network]
    # generateResolvConf = false
    nameserver fec0:0:0:ffff::1
    nameserver fec0:0:0:ffff::2
    nameserver fec0:0:0:ffff::3
    search Home
    

    ... which is close, but notice the search line is missing the tailscale domain?

    Fix

    1. I removed the resolv.conf again (sudo rm /etc/resolv.conf in WSL)
    2. I shutdown WSL (wsl --shutdown via an admin/elevated cmd)
    3. I disabled the "Tailscale" (Tailscale Tunnel) network adapter in Network Connections
      explorer_2024-02-22_18-51-27
    4. Started WSL again...
    ... and now my DNS in WSL is fixed!
    
    $ cat /etc/resolv.conf
    # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
    # [network]
    # generateResolvConf = false
    nameserver 192.168.0.1
    nameserver 205.171.3.25
    nameserver 2001:428::1
    search Home
    $ dig google.com
    

    ; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> google.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12874
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

    ;; OPT PSEUDOSECTION:
    ; EDNS: version: 0, flags:; udp: 1232
    ; COOKIE: 8dc1cce36c2a16b30100000065d7fa3fef29bcd1cacc18e0 (good)
    ;; QUESTION SECTION:
    ;google.com. IN A

    ;; ANSWER SECTION:
    google.com. 188 IN A 142.250.72.14

    ;; Query time: 4 msec
    ;; SERVER: 192.168.0.1#53(192.168.0.1) (UDP)
    ;; WHEN: Thu Feb 22 18:51:59 MST 2024
    ;; MSG SIZE rcvd: 83

    $ ping google.com
    PING google.com(den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e)) 56 data bytes
    64 bytes from den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e): icmp_seq=1 ttl=116 time=4.23 ms
    64 bytes from den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e): icmp_seq=2 ttl=116 time=3.54 ms
    64 bytes from den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e): icmp_seq=3 ttl=116 time=3.78 ms
    64 bytes from den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e): icmp_seq=4 ttl=116 time=3.86 ms
    64 bytes from den08s06-in-x0e.1e100.net (2607:f8b0:400f:803::200e): icmp_seq=5 ttl=116 time=4.00 ms
    ^C64 bytes from 2607:f8b0:400f:803::200e: icmp_seq=6 ttl=116 time=3.71 ms

    --- google.com ping statistics ---
    6 packets transmitted, 6 received, 0% packet loss, time 25043ms
    rtt min/avg/max/mdev = 3.538/3.853/4.233/0.220 ms

    I hope someone else finds this useful!

  22. derekyle commented on Jun 14, 2024

    @derekyle

    Adding to this for those that have the same issue as me. The above solution didn't work for me because every time I tried to disable the Tailscale tunnel, it would go away and a new connection would instantly start up and be enabled. Instead, I went to properties and unchecked the IPv6 option and it seems to have fixed the DNS problem inside WSL for me. No deletions or resolv.conf or anything else required. Did not even need a restart of WSL.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    L2 FewOS-windowsP2 AggravatingT5 Usability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions