Skip to content
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

generateResolvConf = false doesn't work #7816

Closed
1 of 2 tasks
iranvir opened this issue Dec 10, 2021 · 8 comments
Closed
1 of 2 tasks

generateResolvConf = false doesn't work #7816

iranvir opened this issue Dec 10, 2021 · 8 comments

Comments

@iranvir
Copy link

iranvir commented Dec 10, 2021

Version

Microsoft Windows [Version 10.0.22000.348]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.74.3-microsoft-standard-WSL2

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

I have noticed the following behaviour on my Windows 11 Build:

  1. I create the following entry in /etc/wsl.conf:
[network]
generateResolvConf = false
  1. I remove /mnt/wsl/resolv.conf and the symlink to this file, i.e., /etc/wsl.conf

  2. I create a new /etc/resolv.conf file with the contents nameserver 1.1.1.1

  3. I shutdown wsl using wsl --shutdown command

  4. I restart wsl

  5. The file /etc/resolv.conf has been removed and the /mnt/wsl/resolv.conf has been regenerated.

My other settings in wsl.conf (like default user) works, but everytime the subsystem is restarted, I have to manually create resolv.conf file.

Reproducible on Ubuntu and Alpine Linux

Expected Behavior

I expect WSL2 to not remove (or overwrite) my /etc/resolv.conf file after every WSL2 restart.
If possible, I would love to have a global option to completely disable this feature from using .wslconfig option.

Actual Behavior

After setting generateResolvConf = false in wsl.conf. WSL2 removes my custom /etc/resolv.conf after every restart.

Diagnostic Logs

No response

@ggrn
Copy link

ggrn commented Dec 20, 2021

I think wsl always update /mnt/wsl/resolv.conf and wsl.conf's generateResolvConf = false option just affects to recreation of symlink.

resolve issue steps >>

  1. remove or backup resolv link file. sudo mv /etc/resolv.conf /etc/resolv.conf.bak
  2. hard copy resolv file from link origin. sudo cp /mnt/wsl/resolv.conf /etc/resolv.conf
  3. edit resolv (vi, nano, ...)
  4. restart resolv using wsl --shutdown
  5. check resolv wsl cat /etc/resolv.conf
  6. ping ping google.com successfully

(Windows 11, Ubuntu distro)

@iranvir
Copy link
Author

iranvir commented Dec 20, 2021

Didn't work. The custom /etc/resolv.conf file is still being removed (not even being replaced by the default symlink, just removed)
Also not sure why there's a need to oopy the /mnt/wsl/resolv.conf to /etc/resolv.conf and then edit it. But I did it anyways.

@sboden
Copy link

sboden commented Feb 13, 2022

The commands to execute are as follows:

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

Then restart WSL2. I took the google DNS 8.8.8.8, but you can take another IP address.

@benhillis
Copy link
Member

This behavior has been tweaked in 0.56.3

@iranvir
Copy link
Author

iranvir commented Apr 6, 2022

Tweaked in what way?
Also how do we switch to that particular version?

@nmofonseca
Copy link

This behavior has been tweaked in 0.56.3

Hi @benhillis ,

Can you please provide more details?

I just upgraded windows 10 to windows 11 and now I am facing this exact issue.

/etc/wsl.conf is correctly setup, no symbolic link, everytime I reboot the laptop or shutdown my wsl , boom, resolv.conf gone.

This was working just fine in windows 10 btw.

I would like to see this open again, it doesn't seem to be fixed

@Killerbear
Copy link

same problem here
i got a new workstation at work with windows 11 and now i have the same issue.
WSL in Windows 11 seems to delete the resolv.conf file if generateResolvConf is set to false.

@nmofonseca
Copy link

nmofonseca commented Aug 16, 2022

Hello @Killerbear ,

There is another closed issue where I also commented and I got a solution there, you will need to update to one of the latest releases manually.

#8030 You can check onomatopellan reply to my comment, it explains where you can get it and how to install it. but here it goes the quote

"
@nmofonseca Are you in Windows 11? Since you are blocked I think it's worth trying to install the store version manually. Download the latest .msixbundle file from https://github.com/microsoft/WSL/releases and install it from elevated Powershell like this:

Add-AppxPackage .\Microsoft.WSL_0.58.3.0_x64_ARM64.msixbundle

"

Hope that helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants