WSL icon indicating copy to clipboard operation
WSL copied to clipboard

IP route not working properly for multiple ip address in mirror mode

Open wutje opened this issue 11 months ago • 4 comments

Windows Version

Microsoft Windows [Version 10.0.26100.2894]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

5.15.167.4-1

Distro Version

Debian

Other Software

No response

Repro Steps

Setup WSL2 to use mirrored mode

On Windows add two IP addresses within different subnets to the interface shared between Windows and WSL (e.g. eth0) I am using 192.168.108.21/24 and 10.10.0.202/24 From Windows ensure pinging other hosts in either network works: 192.168.108.1 works, and 10.10.0.4 works. And verify it does so by using the source address from the matching ip i.e.; ping 192.168.108.1 uses 192.168.108.21 as source ip, like wise for the 10.10.0.0 net. This ensures the network is working as expected and properly configured on Windows.

From within WSL verify both configured ip address are available: ip a result: inet 192.168.108.21/16 brd 192.168.255.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet 10.10.0.202/24 brd 10.10.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever

Now try: ip route get 10.10.0.4 result: 10.10.0.4 dev eth0 src 192.168.108.21 uid 1000 cache

It is using 192.168.108.21 instead of the expected 10.10.0.202. Which will fail to ping.

Expected Behavior

ip route get 10.10.0.4 result: 10.10.0.4 dev eth0 src 10.10.0.202 cache

Actual Behavior

ip route get 10.10.0.4 result: 10.10.0.4 dev eth0 src 192.168.108.21 uid 1000 cache

It is using 192.168.108.21 instead of 10.10.0.202.

Note that adding ip route add 10.10.0.0/24 via 10.10.0.203 fixes the problem

Diagnostic Logs

Note that on regular Debian machine the ip route command show a slightly different output: 172.22.0.0/16 dev eth0 proto kernel scope link src 172.22.0.1

While WSL2 shows something like 10.10.0.0/24 dev eth0 proto kernel scope link metric 281

Note the missing src x.x.x.x in WSL output.

I also verified this behavior on another machine, so it is not just my machine or setup.

The log does not contain actual commands being run. Just added for version etc. WslNetworkingLogs-2025-02-04_11-50-44.zip

wutje avatar Feb 04 '25 11:02 wutje

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
Detected appx version: 2.3.26.0
optional-components.txt not found

github-actions[bot] avatar Feb 04 '25 11:02 github-actions[bot]

It seems that #10137 and #9803 are similar issues but those where closed due to inactivity and did not pin point the problem to ip route showing the issue.

wutje avatar Feb 04 '25 11:02 wutje

Any update on this?

wutje avatar May 15 '25 14:05 wutje

If the src can be configured to the corresponding secondary ip address when automatically creating the route, ping will works properly.

Default, ping not working:

# ip route
default via 192.168.8.1 dev eth2 proto kernel metric 45
192.168.0.0/24 dev eth0 proto kernel scope link metric 291
192.168.5.0/24 dev eth0 proto kernel scope link metric 291
192.168.8.0/24 dev eth2 proto kernel scope link metric 301
192.168.8.1 dev eth2 proto kernel scope link metric 45

Update, working

# ip r change 192.168.5.0/24 dev eth0 proto kernel scope link metric 291 src 192.168.5.254
# ip route
default via 192.168.8.1 dev eth2 proto kernel metric 45
192.168.0.0/24 dev eth0 proto kernel scope link metric 291
192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.254 metric 291
192.168.8.0/24 dev eth2 proto kernel scope link metric 301
192.168.8.1 dev eth2 proto kernel scope link metric 45

The eth2(192.168.8.*) is WLAN network interface in WSL.

listenerri avatar Jun 06 '25 07:06 listenerri