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

Cheatsheet tips for 'network unreachable' in WSL #252

Merged
merged 2 commits into from
Jan 20, 2021
Merged

Cheatsheet tips for 'network unreachable' in WSL #252

merged 2 commits into from
Jan 20, 2021

Conversation

bluepostit
Copy link
Contributor

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.

Comment on lines 47 to 49
sudo mv /etc/resolv.conf /etc/resolv.conf.old
sudo touch /etc/resolv.conf
sudo echo "[network]\ngenerateResolvConf = false\n" >> /etc/resolv.conf
Copy link
Contributor

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.

Copy link
Contributor Author

@bluepostit bluepostit Jan 20, 2021

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.

Copy link
Contributor Author

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)

Copy link
Contributor Author

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")

Copy link
Contributor

@barangerbenjamin barangerbenjamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙏

@barangerbenjamin barangerbenjamin merged commit 1633d7e into lewagon:master Jan 20, 2021
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

Successfully merging this pull request may close these issues.

2 participants