Skip to content

Instantly share code, notes, and snippets.

@kthy
Created June 16, 2023 21:36
Show Gist options
  • Save kthy/b35babc226c7b29a2d56100e4532571d to your computer and use it in GitHub Desktop.
Save kthy/b35babc226c7b29a2d56100e4532571d to your computer and use it in GitHub Desktop.
Add Windows host DNS entry in Ubuntu/WSL
if ! $(cat /etc/hosts | grep -q 'winhost'); then
echo 'Adding DNS entry for Windows host in /etc/hosts'
echo '# Windows host - added via ~/.bashrc' | sudo tee -a /etc/hosts
echo -e "$(grep nameserver /etc/resolv.conf | awk '{print $2, " winhost"}')" | sudo tee -a /etc/hosts
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment