Created
June 27, 2022 07:43
-
-
Save johananl/ee1623b8fc3d4fe65f8fe2e9c0efda02 to your computer and use it in GitHub Desktop.
Set WSL DNS to Windows host
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
#!/bin/bash | |
set -x | |
set -eou pipefail | |
gw=$(ip route | grep default | awk {'print $3'}) | |
echo Fixing DNS | |
chattr -i /etc/resolv.conf | |
sed -i "1s/nameserver.*/nameserver ${gw}/" /etc/resolv.conf | |
chattr +i /etc/resolv.conf | |
echo Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment