Skip to content
vast-cow's blog
Go back

Workaround for WSL1 DNS issue

Edit page
# Windows
wsl -d {distro}

# WSL
echo -e '[network]\ngenerateResolvConf = false' >> /etc/wsl.conf
exit

# Windows
wsl -t {distro}
wsl -d {distro}

# WSL
rm /etc/resolv.conf
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -NoProfile -Command '$ifs=@(Get-NetRoute -DestinationPrefix "0.0.0.0/0","::/0" -ErrorAction SilentlyContinue | Sort-Object RouteMetric,InterfaceMetric | Select-Object -ExpandProperty InterfaceIndex -Unique); $dns=foreach($i in $ifs){ (Get-DnsClientServerAddress -InterfaceIndex $i).ServerAddresses }; $dns | Where-Object { $_ } | Select-Object -Unique | ForEach-Object { "nameserver $_" }' | tr -d '\r' > /etc/resolv.conf

Edit page
Share this post:

Comments


Previous Post
Container Definitions to Run OpenWebUI (Ubuntu 24.04 / Dockerfile & Singularity)
Next Post
Installing bcache-tools from Oracle Linux 9 Repository on Rocky Linux 9