Skip to the content.

I recently migrated from WSL1 to WSL2. After the migration, being somebody who prefers to connect to their infrastructure via IPv6, I was struggling with the problem that my WSL2 didn’t have IPv6 connectivity since NAT is default switch setting for the NetAdapter “WSL”.

Long story short, here’s what I did:

1
2
3
4
5
6
7
8
9
10
11
12
# Create a new task in Windows' Task Scheduler (WIN+R => taskschd.msc)
# Trigger: On Boot
# Action 01:
# Script:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
# Arguments:
-command "Set-NetAdapterBinding -ComponentID vms_pp -Name Ethernet -Enable $false"
# Action 02:
# Script:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
# Arguments:
-command "Set-VMSwitch -Name WSL -NetAdapterName Ethernet"

This will remove the “Hyper-V Extensible Switch” binding from the (physical) Ethernet Adapter which is necessary in order to be able to change the WSL Switch to an External one instead of an internal (NAT). Soon after that you will see your eth0 adapter in the WSL getting a valid IPv6 address.

PS: The process of adding the Scheduled Task to your Windows Box can also be automated via PowerShell.