Forked from coltenkrauter/fix-wsl2-dns-resolution.md
Last active
December 30, 2020 17:23
-
-
Save gear20056/762ebf6509723fad6eebd5f58672c64f to your computer and use it in GitHub Desktop.
Fix DNS resolution in WSL2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. Create a file: /etc/wsl.conf. | |
| 2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away | |
| ## /etc/wsl.conf | |
| ----------------------------- | |
| [network] | |
| generateResolvConf = false | |
| ----------------------------- | |
| 3. In a cmd or Powershell, run "PS > wsl --shutdown" | |
| 4. Restart WSL2 | |
| 5. Unlink resolv.conf file. $ sudo unlink /etc/resolv.conf | |
| 6. Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file. | |
| 7. Put the following line in the file | |
| /etc/resolv.conf | |
| -------------------------------------------------------------------------------------------- | |
| nameserver 1.1.1.1 # Or use your DNS server instead of 8.8.8.8 which is a Google DNS server | |
| -------------------------------------------------------------------------------------------- | |
| 8. Repeat step 3 and 4. You will see git working fine now. | |
| Credit: https://github.com/microsoft/WSL/issues/4285#issuecomment-522201021 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment