Created
May 25, 2022 07:50
-
-
Save rajshrimohanks/afad5f14fda76f1beeb61b27b4c4d125 to your computer and use it in GitHub Desktop.
Prevents WSL2 from overwriting resolv.conf everytime and persists the resolv.conf file.
This file contains 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
#!/usr/bin/env bash | |
sudo rm /etc/resolv.conf | |
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' | |
sudo bash -c 'echo "[network]" > /etc/wsl.conf' | |
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf' | |
# Make resolv.conf immutable so that the OS can't change it. | |
# If you'd like to make changes to this file later, you've to | |
# make it mutable again by issuing the following command: | |
# sudo chattr -i /etc/resolv.conf | |
sudo chattr +i /etc/resolv.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment