-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Cheatsheet tips for 'network unreachable' in WSL #252
Cheatsheet tips for 'network unreachable' in WSL #252
Conversation
wsl_cheatsheet.md
Outdated
sudo mv /etc/resolv.conf /etc/resolv.conf.old | ||
sudo touch /etc/resolv.conf | ||
sudo echo "[network]\ngenerateResolvConf = false\n" >> /etc/resolv.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello 👋
Thank you for contributing.
I could be wrong but I think that /etc/resolv.conf
is automatically generated by WSL. Anything modified in there would be overridden on the next restart.
The real fix here is the wsl --shutdown
Can we remove the second part about adding a custom DNS server? 🙏
Many thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there :)
You are correct; /etc/resolv.conf
is auto-generated by WSL upon startup.
This auto-generation can be prevented by line 49 above - however, I realize that the end of that line should read /etc/wsl.conf
, not /etc/resolv.conf
. I'll change that and update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See this solution, which describes the same thing I am suggesting in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify - the second part does not add a custom DNS server; it adds the address of a custom DNS server to be used for resolving host names by WSL. For whatever reason, the auto-generated one does not work, and this prevents internet access by WSL.
Also, wsl --shutdown
did not solve the problem without doing the steps I outlined in the second part ("Add a custom DNS server address to WSL")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙏
Added 2 solutions for 'network unreachable' errors in WSL.
These have helped students whose WSL instances could not connect to the internet, either during setup or to download gems.