microsoft / microsoft/WSL

Is that possible to setup wsl2 default nic (eth0) to "Enable spoofing of MAC addresses"

Open
#7,192 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Is your feature request related to a problem? Please describe.

Make the linux network namespace can be used the Linux Bridge to access the external network (Not with the Nat, But with the Bridge mode).

My test environment:
  • WSL2 Default Virtual Switch
    1. Name: WSL
    2. Set up the extra IP address: New-NetIPAddress -IPAddress "192.168.15.1" -PrefixLength 24 -InterfaceAlias "vEthernet (WSL)"
  • WSL2 instance:
    1. Linux Distro: Ubuntu-20.04
Ubuntu-20.04 network configuration:
#1. Setup the bridge
ip link add br0 type bridge
ip link set br0 up

#2. Add the `eth0` nic to the `br0`
ip addr flush eth0 
ip link set eth0 master br0

#3. Define the IP address for the `br0`
ip addr add 192.168.15.11/24 dev br0

#4. Define the network namespace
ip netns add ns1

#5. Define the type of `veth` peer virtual interfaces
ip link add veth0 type veth peer name veth1
ip link set veth0 up

#6. Add the `veth1` to the `ns1` network namespace,and config the IP address to the `veth1`
ip link set veth1 netns ns1
ip netns exec ns1 ip addr 192.168.15.21/24 dev veth1
ip netns exec ns1 ip link set veth1 up
Network ping test:
#1. `br0` ping the virtual switch `WSL`, it was successful.
ping -c 1 192.168.15.1
> PING 192.168.15.1 (192.168.15.1) 56(84) bytes of data.
> 64 bytes from 192.168.15.1: icmp_seq=1 ttl=128 time=0.283 ms

#2. In th `ns1` namespace, use `veth1` ping the virtual switch `WSL`, it was failed.
ip netns exec ns1 ping -c 192.168.15.1
> PING 192.168.15.1 (192.168.15.1) 56(84) bytes of data.

> --- 192.168.15.1 ping statistics ---
> 1 packets transmitted, 0 received, 100% packet loss, time 0ms

Describe the solution you'd like

I repeated the test in the Virtual Box and Hyper-V environment,it was successful.

The Virtual Box should set the vm network as follows:

image

The Hyper-V should set the vm network as follows:

image

And the linux network namespace can be used the Linux Bridge to access the external network.

Describe alternatives you've considered
None.

Additional context
None.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points. Start by reproducing the WSL2 bridge and network-namespace commands, then investigate how the WSL2 default virtual switch handles MAC spoofing and bridged traffic; done means a namespace attached through the Linux bridge can reach the external network.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, ubuntu
Domain
networking, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.