WSL2 is used to create the 'vEthernet (WSL)' adapter with IP address 172.23.0.1 after each reboot. Worked fine so far, until our company decided to add another network on 172.23.0.0/20 and updated the routing table.
Problem
Now, network communication from and to WSL (Ubuntu) is not possible anymore, since every traffic to WSL gets routed to a different interface because fo the new route and gets lost in limbo. I observed that via Wireshark. Changing the route is not an option - I need to access the new network.
Option 1
I am looking for a way to tell WSL to use a different IP address when creating the 'vEthernet (WSL)' adapter after reboot (when you first start WSL). Unfortunately, it recreates the adapter each time using the same IP address. I have not found any information how or where to set a default IP for the WSL ethernet adapter.
Option 2
I tried assigning new IP addresses to the host adapter and Ubuntu according to https://gist.github.com/wllmsash/1636b86eed45e4024fb9b7ecd25378ce
- changed vEthernet (WSL) adapter IP address to 172.30.0.1, removed 172.23.0.1
- removed 172.23.x.x IP address from Ubuntu and added 172.30.0.2
- replaced default route on Ubuntu with 172.30.0.1
I have aswell been trying around with the firewall rules for inbound/outbound traffic on the vEthernet (WSL) adapter.
Results:
- I can successfully ping the Ubuntu machine from the windows host.
- I can successfully pint the windows host (172.30.0.1) from the Ubuntu machine (after deleting and readding the firewall rules).
- I can not access the internet from Ubuntu. I can only see the traffic from Ubuntu to windows host on the vEthernet (WSL) interface, but no more outgoing traffic on the normal network interface of the windows host.
Any hints whats missing? I'd prefer a solution regarding Option 1, since I am not really looking forward changing the network config of the WSL subsystem after each reboot.