Custom resolv.conf being replaced by generated file, even with comment removed.
-
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
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?
Did you modify /etc/resolv.conf or /run/resolvconf/resolv.conf?
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.
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.
Sorry, did not mean to close.
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.
The problem still persists in Insider Preview 16241. I solved this issue by following steps
- Delete /etc/resolv.conf
- Make /etc/resolv.conf by vim/nano
- Insert appropriate nameservers.
- Done!
Logout and the again run bash on cmd
@sunilmut is currently looking at this.
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.
followed @bradley101 workaround and back in business.
Issue is still there in current Windows release
followed @bradley101 and it works
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.
This fella helped me out with this issue: https://grayson.sh/blogs/fixing-wsl-search-domains
@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.
How has this not yet been fixed?
Can confirm. The file is still being overridden whenever bash.exe is executed. None of the proposed solutions worked for me.
The workaround provided does not survive a reboot. Come on guys, it's been 3 years.
@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.
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?