WSL: generateResolvConf = false did not work in wsl.conf
I have WSL2 with debian -all good. I created a /etc/wsl.conf file it contains
[network]
generateResolvConf = false
as per https://docs.microsoft.com/en-us/windows/wsl/wsl-config#network
if i delete /etc/resolv.conf (or edit and save) on start of the next debia WSL2 session it has been regenerated again.
running WSL2 in windows 10 build 20170.rs_prerelease.200710-1419
Environment
Windows build number: Microsoft Windows [Version 10.0.20170.1000]
Your Distribution version:
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
WSL 2
Steps to reproduce
Expected behavior
Actual behavior
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 11
- Comments: 15
OMG, I hate Microsoft so much. How are you still in business when you cannot make a single piece of software that isn’t fundamentally broken and riddled with bugs? Upgrade from WSL1 to WSL2 fails. Useless error message. Googling provides help, WSL2 won’t install on compressed drive, gets upgrade working. Boots upgraded distro. Network broken. No help. Googling lets you know that you need to install a kernel package thing.
wsl --set-versionneither did this nor mentioned it needed to be done. Do it manually. Network still broken. Internet helps you to know that you need the Hyper-V feature enabled.wsl --set-versionneither did this nor mentioned it needed to be done. Network still broken. Internet tells you that if your temporary folder is compressed, WSL2 can’t create a swap file in %TEMP%. No error message provided by WSL to tell you this, no mention of it anywhere, WSL incapable of itself creating the uncompressed VHD file it needs because incompetence and brain damage. Network still broken. WSL for reasons unknown (aka incompetence and brain damage in the room in Redmond filled with drunken clowns with “Developers” written on the door) puts in a random DNS ip in resolv.conf. This is generated automatically, unless, as Google again helps you to understand you need to addgenerateResolvConf = falsein your[network]session in the%userprofile%/.wslconfigfile that you just created to get WSL2 to not attempt to create the swap file it doesn’t know how to create. Alright, I mean, we are riding the clown car, so let’s just keep on smashing windows and pouring sugar in the tank. Fine, add the setting, shut down, restart and edit resolv.conf. Works until I open up another WSL session which overwrites resolv.conf because… Yeah, incompetence and brain damage. This isn’t beta. This isn’t alpha. This is “oh, I’m sorry, we don’t have a position for you, because you’re not actually a developer, you’re a clown with brain damage.” I hate you so, so much, Microsoft. The only thing worse than trying to use your brittle self-destructing pain-inflicting clownish garbage you call software, would be forced to work alongside the clowns you call developers. Imagine that nightmare. Christ.The need to shutdown WSL for this setting to take effect should be stated as a comment in the default
/etc/resolv.conf.M$ keep closing these bug tickets without solving the bug. Or they keep repeating and making this bug worse with every update.
Windows 10 Entrprise H20 it does not matter what you shutdown it has no absolutely effect. You can cold reboot the computer and it has no effect, the resolv.conf is always overwritten. Now even if you try to make the file immutable chattr +i /etc/resolv.conf, that no longer works.
And why this setting is not available in global .wslconfig ?
A
wsl.exe --shutdown(rather than mucking LxssManager) should be sufficient. Yeah that is (as a practical matter) by-design for better or worse. It isn’t the service, which is responsible for managing the state of all distros (both WSL1 and WSL2). Your/etc/wsl.confis read at the point WSL-brand/initfired up for a given distro. Once/inithas started and is running, it is oblivious to changes that happen in/etc/wsl.conf.Works to me
sudo rm /etc/resolv.conf sudo bash -c ‘echo “nameserver 8.8.8.8” > /etc/resolv.conf’ sudo bash -c ‘echo “[network]” > /etc/wsl.conf’ sudo bash -c ‘echo “generateResolvConf = false” >> /etc/wsl.conf’ sudo chattr +i /etc/resolv.conf
https://github.com/microsoft/WSL/issues/5420#issuecomment-646479747
It works for me (the first time I forgot to remove symlink and I got the problem)
sudo rm /etc/resolv.confStill happening on Windows 11 even after the update that came out literally yesterday/today. No dice on any of the fixes.
here
Why is this closed? The issue still persists.
@mikezerosix i see the same behaviour with a fresh Ubuntu 22.04 installed through the Microsoft Store. I am on Windows 10 Version 10.0.19044 Build 19044
wsl --shutdown did not help either.
It is working fine though with Ubuntu 18.04 and 20.04
EDIT: a reboot of the host did the trick
solution seems to have been restarting LxssManager - maybe wsl.conf is only read once per boot (per start of the service?) . is that expected or a bug?