I have set up WSL2 with Ubuntu 20.04 and use it for web development. On WSL2 I have installed a LAMP stack.
I have set up some vhosts with apache in WSL2. So far it is working fine. But what I find annoying is that I have to set every day the new IP that I get for WSL in the Windows hosts file.
I have tried to set a static IP in Ubuntu, but I am not quite sure if it is the right way and if it is working. I have created in the /etc/netplan folder a file with an IP. Mainly I followed this advice.
I have set an IP address but I get an error when I do sudo netplan apply.
I have also tried this approach and wrote a PowerShell script. But I don't know how this should set the IP.
I would be happy and grateful for any suggestions.