Hyper-V creates a hidden virtual switch for WSL2. In Windows, the virtual NIC vEthernet (WSL)
is connected to the
switch. In WSL2 (Ubuntu), the virtual NIC eth0
is connected to the switch. Communication between the two network
endpoints happens over the switch. The virtual NICs (and possibly the switch) are ephemeral and disappear at host system
restart time. The NICs are recreated on demand when WSL2 first runs.
To use a custom static IP address we can assign each of the NICs to IP addresses on a shared subnet. It's a good idea to pick a subnet in the Private Address range.