Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacAddressSpoofing not working for WSL2 bridged adapter #8602

Closed
1 of 2 tasks
xJason6 opened this issue Jul 13, 2022 · 5 comments
Closed
1 of 2 tasks

MacAddressSpoofing not working for WSL2 bridged adapter #8602

xJason6 opened this issue Jul 13, 2022 · 5 comments

Comments

@xJason6
Copy link

xJason6 commented Jul 13, 2022

Version

Microsoft Windows [Version 10.0.19042.1766]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16

Distro Version

Ubuntu-20.04

Other Software

Hyper-V Manager 10.0.19041.1

Repro Steps

  1. Stop WSL:
wsl --shutdown
  1. Change connection type via Hyper-V Manager -> Virtual Switch Manager -> WSL
    Set type to "External" and choose ethernet adapter with static ip address set (e.g. 192.168.1.2)
  2. Enable MacAddressSpoofing on WSL Network Adapter:
Set-VMNetworkAdapter -ManagementOS -Name WSL -MacAddressSpoofing On
  1. Run WSL and set static IP address on eth0 adapter in Ubuntu, e.g.:
sudo ip addr add 192.168.1.3 dev eth0
  1. Ping Windows host:
ping 192.168.1.2

SUCCESS
6. Change Ubuntu eth0 MAC address, e.g.:

sudo ip link set dev eth0 down
sudo ip link set dev eth0 address 00:15:5d:7a:02:51
sudo ip link set dev eth0 up
  1. Ping Windows host again:
ping 192.168.1.2

FAIL

Expected Behavior

Since MacAddressSpoofing is enabled traffic should not be blocked after MAC change and ping should succeed.

Remarks:

  • This seem similar to WSL 2 - Static MAC Address or Changing MAC After Booting Without Breaking Internet Connection #5352 but there MacAddressSpoofing was not mentioned. Also switch was in default "Internal" mode.
  • If the command to enable MacAddressSpoofing is wrong, what is the correct one and what does the setting I used really do as I cannot see any effect of it but the change is accepted without errors and setting is really modified.
  • The issue originated from the fact that I tried to run nested VM in Ubuntu and despite I can ping host and nested VM from Ubuntu, traffic from nested VM to host is blocked due to different MAC address - wanted to provide minimal working example however to prove the issue.

Actual Behavior

Ping fails since all MAC addresses except default one are blocked.

@Biswa96
Copy link

Biswa96 commented Jul 13, 2022

It is possible to change MAC address of the virtual NIC in another way. I do not know if it is possible with Set-VMNetworkAdapter. To change MAC address of WSL2 NIC, I removed the attached network endpoint and create a new one with different MAC address. Then attached it with WSL2 VM. I have shared the code in that thread.

@xJason6
Copy link
Author

xJason6 commented Jul 13, 2022

This issue is not about changing the MAC - it's about MacAddressSpoofing not working. I already provided some information how I stumbled upon this issue: I cannot set same MAC on both Ubuntu and nested VM. So what I want to achieve is unblocking other MAC addresses than default one - this is what I think MacAddressSpoofing option is for.

@tadshi
Copy link

tadshi commented Jul 16, 2022

Also run into this problem these days. I'm trying to set up my QEMU, which use a tap interface for its network, on WSL2. Appreantly, the packets from QEMU have a unique source MAC address. I managed to bridge the tap interface and eth0, but when I use wireshark to dump the traffic of eth0(on WSL2) and the traffic of vEthernet interface(on Windows) it just doesn't work. Only packets whose source MAC address is identical to eth0's can be captured on Windows.

I have tried to set MACAddressSpoofing on the adapter but there's no luck. And adding another dummy adapter with tap MAC address to WSL switch in hope of fooling the adapter does not work as well.

So I'm curious about how to pass a packet with arbitary source MAC address from WSL2 to Windows. I keep the WSL switch an internel switch so this problem may not be limited to an externel switch.

By the way, This thread on Superuser give more details but it seems that no solution has been found.

@xJason6
Copy link
Author

xJason6 commented Jul 21, 2022

The thread on Superuser is mine - I tried to clarify the origin of the problem with nested VM networking and possibly find a workaround but it came out that the real problem is MAC filtering and the fact that the MAC spoofing doesn't work for WSL2 adapter. This is why I reported this issue.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants