Skip to content

Instantly share code, notes, and snippets.

@jimathyp
Last active July 17, 2020 03:27
Show Gist options
  • Save jimathyp/3cecf196463887084d15580d67d0f9d9 to your computer and use it in GitHub Desktop.
Save jimathyp/3cecf196463887084d15580d67d0f9d9 to your computer and use it in GitHub Desktop.

DNS lookups in WSL

/etc/resolv.conf

in a cmd window (WSL2?)

wsl --shutdown

Create or append to file /etc/wsl.conf

[network]

generateResolvConf = false

microsoft/WSL#1350 DNS server coming from vpn network is not reflected in WSL

By default, bash.exe will auto-generate /etc/resolv.conf every time you launch bash.exe. Then it will try to keep it up to date with changes from Windows, when bash is running.

in /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.

ordering of the dns servers is incorrect when the vpn is connected

In PowerShell

Get-DnsClientServerAddress -AddressFamily ipv4 | Select-Object -ExpandProperty ServerAddresses
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment