WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Custom resolv.conf being replaced by generated file, even with comment removed.

Open j-c-m opened this issue 9 years ago • 44 comments

  • A brief description Custom /etc/resolv.conf overwritten, even when "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line." is removed.

  • Expected results Custom /etc/resolv.conf should not be overwritten when comment is removed.

  • Actual results (with terminal output if applicable) Custom /etc/resolv.conf replaced with standard generated /etc/resolv.conf

  • Your Windows build number 1703 - OS Build 15063.138

j-c-m avatar Apr 13 '17 16:04 j-c-m

If I remove /etc/resolv.conf - which was a symlink -> /run/resolvconf/resolv.conf it will not remove my custom /etc/resolv.conf.

I can't verify but is it possible that this behavior changed from 14.04 -> 16.04 so the symlink isn't being followed by WSL when checking for the comment?

j-c-m avatar Apr 13 '17 17:04 j-c-m

Did you modify /etc/resolv.conf or /run/resolvconf/resolv.conf?

benhillis avatar Apr 13 '17 17:04 benhillis

If the /etc/resolv.conf symlink was in place it would implicitly only modify /run/resolvconf/resolv.conf - and changes would always be automatically overwritten as long as /etc/resolv.conf was a symlink.

j-c-m avatar Apr 13 '17 18:04 j-c-m

It looks like there is an issue that is causing the resolv.conf file to be regenerated each time an instance is launched. We are looking at ways to improve this experience.

benhillis avatar Apr 17 '17 23:04 benhillis

Sorry, did not mean to close.

benhillis avatar Apr 17 '17 23:04 benhillis

Here is some more background. By default, bash.exe will auto-generate /etc/resolv.conf every time you launch bash.exe. Then it will try to keep it up to date with changes from Windows, when bash is running. We somehow screwed up the logic to stop-auto generation when you remove the first line. It looks like if you remove the first line, we stop auto-update of the file while bash is running, but forgot to disable the logic to auto-generate during bash launch. We do apologize for the inconvenience and as @benhillis mentions, we are looking to improve the experience here.

sunilmut avatar Apr 21 '17 19:04 sunilmut

The problem still persists in Insider Preview 16241. I solved this issue by following steps

  1. Delete /etc/resolv.conf
  2. Make /etc/resolv.conf by vim/nano
  3. Insert appropriate nameservers.
  4. Done!

Logout and the again run bash on cmd

bradley101 avatar Jul 17 '17 17:07 bradley101

@sunilmut is currently looking at this.

benhillis avatar Jul 17 '17 19:07 benhillis

Thanks @bradley101. For this release (Fall Creators Update), we will have to live with the workaround you have pointed out, here. For next release, we will relook at the better support for other VPN solutions.

sunilmut avatar Jul 25 '17 19:07 sunilmut

followed @bradley101 workaround and back in business.

lmayorga1980 avatar Nov 29 '18 18:11 lmayorga1980

Issue is still there in current Windows release

daghb avatar Nov 30 '18 12:11 daghb

followed @bradley101 and it works

ManuCasl avatar Jan 16 '19 15:01 ManuCasl

FTR this matter remains an issue as part of Win 10 Pro Build 17134.

That said, @bradley101 's solution worked for me on my Win 10 Ubuntu WSL provided I didn't reboot my PC. The resolv.conf content remained in tact after multiple open/closes of Ubuntu WSL and also after connecting/disconnecting to my VPN.

That said, following a system reboot the /run/resolvconf/resolv.conf is regenerated and thus in turn the symlinked /etc/resolv.conf file reflects this change.

Cheers.

jvosper avatar Feb 13 '19 15:02 jvosper

This fella helped me out with this issue: https://grayson.sh/blogs/fixing-wsl-search-domains

andrewr01 avatar Feb 19 '19 05:02 andrewr01

@andrewr01 that link to Kent Grayson's blog worked for me. Thanks for providing it!

I would say to anybody looking to employ Kent's solution that you may want to keep an original copy of the resolv.conf instead of moving it wholesale like his instructions promote. Otherwise, I appear to be good for now and will report back if anything comes up.

jvosper avatar Feb 21 '19 21:02 jvosper

How has this not yet been fixed?

gustavlasko avatar Mar 10 '20 12:03 gustavlasko

Can confirm. The file is still being overridden whenever bash.exe is executed. None of the proposed solutions worked for me.

MrSleazy avatar Mar 25 '20 00:03 MrSleazy

The workaround provided does not survive a reboot. Come on guys, it's been 3 years.

michaelklachko avatar Mar 26 '20 22:03 michaelklachko

@gustavlasko , @KevinSilvaQuintana , and @michaelklachko the workaround noted by @andrewr01 back on Feb 18, 2019 has persisted for me since I noted as much on Feb 19.

jvosper avatar Mar 26 '20 23:03 jvosper

I feel like rm'ing a symlink and 'sudo cat content >> /etc/resolv.conf' should not be part of my daily workflow anymore, does anyone know if this is going to be fixed in the WSL 2 general release?

asyncjake avatar Mar 31 '20 18:03 asyncjake