Skip to content

Instantly share code, notes, and snippets.

@aont
Last active December 13, 2025 06:51
Show Gist options
  • Select an option

  • Save aont/5a01144acf77efd3aca502d838b7b928 to your computer and use it in GitHub Desktop.

Select an option

Save aont/5a01144acf77efd3aca502d838b7b928 to your computer and use it in GitHub Desktop.

Workaround for WSL1 DNS issue

echo '[network]
generateResolvConf = false
' >> /etc/wsl.conf

# ????
DNSSERVER=8.8.8.8
echo nameserver "$DNSSERVER" > /etc/resolv.conf
apt-get update

DNSSERVER="$(powershell.exe -c "(Get-DnsClientServerAddress -InterfaceIndex ((Get-NetRoute -DestinationPrefix '0.0.0.0/0' | sort RouteMetric,InterfaceMetric | select -First 1).InterfaceIndex) -AddressFamily IPv4).ServerAddresses")"
echo nameserver "$DNSSERVER" > /etc/resolv.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment