how to associate windows hosts file entry with process running on WSL

Viewed 9993

I am running WSL2 (ubuntu) on Windows 10. The WSL is running a process thats listening on a particular IP address - 192.168.3.1 (my apologies if I am not phrasing it correctly)

When I am in Windows browser, I want to type some name and have it resolved to the IP address inside WSL.

I have edited the Windows hosts file, and said something like:

192.168.3.1    alex

So now, in the browser, when I enter "alex" in the URL, I dont want it to search the internet -- I want it to get resolved to 192.168.3.1 inside WSL.

Thank you

1 Answers

Try this on WSL2:

cd /etc <br>
sudo mv hosts hosts_bkp <br>
sudo ln -s /mnt/c/Windows/System32/drivers/etc/hosts hosts

Now try to edit your hosts file by Windows.

Related