There are tons of gists available for this problem:
However even solution is there - I was not satisfied that this probalem alaways persists and I had to do same steps again from time to time
This guide describes the permanent solution using brand-new WSL boot command.
- login to your wsl and run
sudo bash. It's important that you do this with a root user because it's a user which executes this command during boot - change to ~ folder ( or use any folder you like )
- create a new file for example
boot.shand update it with a content from boot.sh gist - make it executable with
chmod +x boot.sh - create a symbolic link in one of PATH folders ( keep in mind, that for root user number of path folders is very limited by default )
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
- i have used
ln -s ~/boot.sh /usr/local/bin/boot.sh - having such a limited list of folders makes root not aware of powershell.exe and rest of window utilities. I have preferred to use an absolute path like
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exein my script - but you may think of creating a symlink for powershell too. - now let's add boot command to
/etc/wsl.conffile. In my case it looks like this:
[network]
generateResolvConf=false
[boot]
systemd=true
command=boot.sh
- now just
exitfrom bash, from wsl as well. Terminate your wsl with a command likewsl -t Ubuntuand start again - if everything went well
cat /etc/resolv.confshould have nameservers from your Windows