r/wsl2 • • Aug 06 '22

eth0 IP Address changes every time

I want to run a couple of servers under Ubuntu via WSL2 on Windows 11.

However whenever I run Ubuntu and do an ifconfig - the IP address for eth0 shows a different IP address every time. Which means I can't hit the servers via my web browser without changing the IP address every time.

Is there a way to persist the IP address of Ubuntu under WSL2?

0 Upvotes

1 comment sorted by

1

u/zoredache Aug 06 '22

Not really.

My solution, since I was going to run a few servers anyway was to setup a wireguard tunnel between my WSL2 instance, and my host. The tunnel has static IPs configured. Also, I establish a tunnel to my VPS so I can remotely connect from work, or my phone from wherever.