Skip to content

Instantly share code, notes, and snippets.

@johananl
Created June 27, 2022 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johananl/ee1623b8fc3d4fe65f8fe2e9c0efda02 to your computer and use it in GitHub Desktop.
Save johananl/ee1623b8fc3d4fe65f8fe2e9c0efda02 to your computer and use it in GitHub Desktop.
Set WSL DNS to Windows host
#!/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