-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/etc/resolv.conf gets removed on shutdown/startup #6977
Comments
Thanks for your report @TotiTolvukall, WSLg doesn't touch this file. This sounds like a possible recent regression in WSL core. @benhillis as fyi. I'll move this issue to the main WSL github to get this investigated further. |
sudo cat > resolv.conf Suspicious command line. |
@0xbadfca11 how about at least making an attempt at understanding what's being done before commenting like that? No, it's not unsuccessful. It's perfectly successful. try it on a different file. sudo rm -f filethatdidntexist && sudo cat > filethatdidntexist << EOT You will be asked for a password - type it in correctly and the SECOND sudo will run without a password. But THIS is a digression. The original problem is that of resolv.conf being deleted at boot/shutdown and that is what this ticket should address, not script semantics (regardless if you do understand them or not). |
Check out #5420 (comment) See if that sequence helps |
@SheepReaper the problem isn't the shutdown itself (and I wouldn't have reported it unless I'd tried all kinds of WSL shutdowns - including full computer reboots). The problem is the procedure running (I suspect at start-up, not shutdown as you normally want your autogenerated resolv.conf to be generated from the current settings, not the settings when you last turned off your computer) at start-up. Without having dug into it, my gut feeling tells me;
But is more like this
Just a gut feeling, but it matches up to what I'm seeing. For now, I have a /etc/resolv.conf.real which is my actual resolv.conf file, and then at EVERY reboot of my computer or fresh startup of WSL, I do "sudo ln -s /etc/resolv.conf.real /etc/resolv.conf" |
Same issue here.
EDIT: Linux version - Ubuntu 20.04 LTS
|
I got the same result. a working workaround for now: Full configuration:
The real bug here is that the But despite the current bug, I still think this whole process needs some design, at least more clear document in /etc/resolv.conf
|
Omg, this script worked, thank you very very much |
Typically this is happening because /etc/resolv.conf is a symlink to tmpfs. If you want to take ownership of this file, set the /etc/wsl.conf setting, and replace the /etc/resolv.conf symlink with a regular file. |
It would be respectful to ALL the people in this thread @benhillis to at least glance over the discussion so far before replying with an entry that has zero weight. It has already been concluded that by disabling WSL from messing with the resolver, it removes all traces of resolv.conf - symbolic links as well as regular files. And does so repeatedly (i.e. on every startup/restart.) Thus the issue. |
@TotiTolvukall - I appreciate you taking the time to file this issue, turns out there was some refactoring that introduced this issue. I'll get this sorted out. This issue has a very common signature of a common pitfall people often run into, I apologize I got this conflated with that one. |
hi! |
@benhillis any news on this ? I'm also having this issue on Windows 11 build 22000.318 |
Same problem, Windows 11 build 22000.318 |
keeps the file after a reboot for me. It's not great, but serious kudos for suggesting that! |
This bug is damn annoying, and open since May, and now has wheedled itself into Windows 11. |
I don't recall seeing this behavior in Win10, but definitely confirm this behavior in Win11 |
Not that there aren't valid use cases for specifying /etc/resolv.conf, but the examples above seem to want to use google dns. |
For me at some point last year whatever value WSL came up (within the linked resolv.conf) stopped working, so I ended up manually configuring /etc/resolv.conf (telling WSL to leave resolv.conf alone through /etc/wsl.conf). |
So 2 questions then:
|
|
I was also facing this problem but I fixed it by following steps:
Hope this will also fix your issue :) |
W11 Pro 22H2 with WSL2 Preview (from Store) and Ubuntu (from Store), all fully updated including W11 patch that arrived just a day or two ago (one that enables File Explorer tabs i stable builds). No Insider builds.
For me personally |
Hi @benhillis I think you forgot about this one |
It's possible this is being ignored (frustratingly, because it should at least be closed if they are going to ignore it...) because the documented solution looks like it works now. I'm not the first user to suggest it here, or the second, but here is more system detail if it helps.
Freshly installed and updated version of WSL2, running freshly-installed Ubuntu (the generic distro, not a specific version) from the Microsoft App Store. Installed WSL itself from Windows, not the App Store. Encountered the common problem where my distro could not connect to the internet. Searching led to #5420, which led to this issue.
Happy to provide any additional system info. Tried to start from as clean a setup as possible. Not endorsing the fact that Microsoft let the community struggle with this bug for years, just suggesting that the bug may have been quietly fixed by restoring the intended (but still obtuse) behavior of requiring I did not try a single other intended solution first to preserve integrity, and like many others refused to use the "immutable file" kludge. Hope this helps someone. |
As I mentioned about a month and a half ago, like @boner-cmd I have no issues with my custom |
For me, i was able to get it working again by editing my |
Thanks for all the suggestions here. Just one pattern repeated by many seems fishy: Hope this helps :) |
I encountered this issue after a fresh W11 install a few days ago. I wanted to avoid At this point, I am in Ubuntu and manually created the
Exited Ubuntu and did
|
For whatever reason, version installed from Microsoft Store is NEWER. I'd suggest to uninstall WSL, reboot host PC, and install from MS Store. Running From there on just keep updating from Store. I'm not sure why there's disparity between the installed versions, but several new features are absent as well from non-store versions. |
This bug still exists no matter what. resolv.conf gets deleted from /etc upon shutdown of WSL. |
I still have the issue and I noticed that for me
Reading in EDIT: After backing up my wsl container I ran TL;DR |
If `--version` is unsupported, you are using the in-box wsl. You need to
install wsl from the M$ Store.
…On Mon, Aug 14, 2023, 7:53 AM Leif Linse ***@***.***> wrote:
I still have the issue and I noticed that for me wsl --version says it
doesn't support the --version parameter. I have checked for windows updates.
PS C:\Users\anon> wsl --version
Invalid command line option: --version
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: wsl.exe [Argument] [Options...] [CommandLine]
Reading in `wsl --help` of this version it seems there is a `wsl --update` command that updates the wsl engine.
—
Reply to this email directly, view it on GitHub
<#6977 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLQ6JKDKYGHDW24X22TWZ3XVIGSPANCNFSM45LOHZZQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Windows Subsystem for Linux https://apps.microsoft.com/store/detail/windows-subsystem-for-linux/9P9TQF7MRM4R |
I have the same issue on Win 11 Enterprise,
My workaround is to modify "/etc/wsl.conf" first, then do |
This is really effing annoying BS. Typical MS shit. |
This seems to be the solution for now. It would seem that on first wsl reboot after |
Why isn't this getting fixed. Every now and then, I have to spend whole day fixing these issues on wsl. I guess thats why developers are using macbook. Simply- the OS shouldn't come in way of user. |
Ya, fix this BASIC functionality. I know we all want to contribute to core kernel but this shit is important too!! |
Also seeing this issue. OS: Windows 11 /etc/wsl.conf contains I manually create /etc/resolv.conf, shutdown the running instance, start back up and /etc/resolv.conf is gone. Workaround I'm using is "sudo chattr +i /etc/resolv.conf" |
@aprescott706 are you using the latest, 2.2.1 at the moment, version of WSL? |
I'm not sure to be honest. The command wsl --version/-v doesn't work. File version on wsl.exe is 10.0.22621.1 |
That's because you have the 'in box' version of wsl. You must install wsl from the M$ Store. easiest way to determine you have the wrong version installed. when the M$ store version is installed the output is thus: wsl --version
WSL version: 2.1.5.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3296 |
Sometimes, based on issues addressed, you might want to install the latest preview version here, https://github.com/microsoft/WSL/releases. You can find the binaries by expanding the "Assets" section. |
I have the version you show here an still had to use the posted workaround. This should not require the suggested workaround. (Taut is what you are suggesting, the workaround was required because the user did not have the latest version?). |
Same issue, disabled the automatic generation and on restart the file is gone
|
Experiencing the issue as well WSL version: 2.2.4.0 |
Same issue: WSL version: 1.2.5.0 |
Still don't know if it's a bug or not. But can confirm that disabling resolv.conf generation does in fact delete it, but only for the first So maybe not bug, but very annoying behavior. Why not just leave the file there even if it was originally generated? (Asking MS here) WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.22631.4112 |
My WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26100.2033 |
Environment
Steps to reproduce
Create the /etc/wsl.conf containing the two magic lines:
user@host:/etc$ cat wsl.conf
[network]
generateResolvConf = false
user@host:/etc$
Make sure you have your own resolv.conf:
user@host:/etc$ sudo rm -f resolv.conf && sudo cat > resolv.conf << EOT
nameserver 1.1.1.1
nameserver 8.8.8.8
domain mydomain.com
search mydomain.com
EOT
Password:
user@host:/etc$
In CMD, do a wsl --shutdown
Start WSL Ubuntu 20.04 session again, and check for the /etc/resolv.conf.
It will be gone.
WSL logs:
The wsl logs reveal nothing about resolv.conf
Expected behavior
Expected is that MY resolv.conf is left alone. As it did in the WSL (pre-g release) version.
Actual behavior
Actually my resolv.conf is being forcefully removed - which IS making WSLg unusable until a new one has been put in place.
The text was updated successfully, but these errors were encountered: