-
Open a WSL terminal
-
Copy the contents of
configure-wsl-dns.sh
to/opt/configure-wsl-dns.sh
:sudo nano /opt/configure-wsl-dns.sh
-
Make it executable:
sudo chmod +x /opt/configure-wsl-dns.sh
-
Add a passwordless sudo entry in the file
/etc/sudoers.d/configure-wsl-dns
:%admin ALL = (root) NOPASSWD: /opt/configure-wsl-dns.sh
-
Fix an issue with
dbus
:sudo sh -c "dbus-uuidgen > /etc/machine-id"
-
Update
~/.zshrc
or~/.bashrc
:# WSL networking sudo /opt/configure-wsl-dns.sh export $(</etc/wsl-host.env) # The env var 'WSL_HOST' is now available which # contains the IP of the host machine if you need # it for XServer setup etc.
-
Exit and then go back into WSL terminal
Tested on Ubuntu 20.04 LTS and Windows 10 2004