-
Notifications
You must be signed in to change notification settings - Fork 822
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
No IPv6 connectivity in docker container on win11/wsl2/mirrored #10663
Comments
HI there. can you please collect traces: https://github.com/microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1 There are some known limitations accessing the Windows Host from the Linux container. Are you trying to access an Internet resource from Linux/Docker? Docker has a separate address than what is mirrored? |
We will collect the data in the next days because I'm out of office. We try to reach ipv6 on the internet or via vpn (both did not work). If I enter the ubuntu on wsl i can do ping -6 blog.fefe.de for example. If I start a container and try to ping from the container, it failed via IPv6, but the container got an IPv6 address from the docker pool. Seems that there is some kind of problem with wsl and mirrored network and docker-desktop. |
if you need masquerade, add this to daemon.json.
|
hi, so I got a system for testing. Fresh windows 11 pro 23H2 with wsl2 2.0.9.0 and Docker Desktop v4.25.1.
Docker config:
IPv6 in wsl works without any problem:
But in docker:
I have no idea how the docker desktop integrates wsl2 and windows, cause I normaly use linux. |
@shigenobuokamoto @keith-horton any idea? Or is it a docker problem? |
@ruben-herold
ping seems to work. if ip6tables is enabled, you can find masquerade entry in iptables.
|
@shigenobuokamoto thx good idea. I tried this but this also failed. I can ping from docker IPv6 Adresses but can't do any curl request ore something like that: In wsl it worked:
In docker running on wsl:
If I do an tcpdump on the wsl I can see:
On my gateway I cann see that the packets go out and are send back to the windows machine. |
@keith-horton @shigenobuokamoto also I found out that in docker on wsl all tools seems to prefer IPv4 over IPv6... Seems it has todo with the network fd00 is normaly for ULA and this leads do this. If I take a nother IPv6 range IPv6 will be prevered over IPV4 but still curl will not work.. |
@ruben-herold @keith-horton in the current WSL (2.0.0 - 2.0.11), nft chains WSLOUTPUT and WSLPOSTROUTING have been added.
edited: in the case of inet, it seems to interfere with the rules provided by /init, so change to ip6. ps. the reason why IPv4 is preferred over ULA lies in the specifications of IPv6 itself. |
@shigenobuokamoto @keith-horton Thx @shigenobuokamoto I can confirm that the nft commands help. Yes the ULA is standard I found it some minutes later and switched to NAT64 space for the docker containers... How can this be fixed permanent? What is the simplest way to give vstudio or vscode on windows access to the docker in wsl? As described at te start of this issue we have developers running windows who develop microservices in dot net core to run in linux containers. They need the posibilty to run the containers from their IDE and must be able to debug the code.. Do you have any idea? |
@ruben-herold as a temporary measure, it may be possible to deal with this by setting nft rule from systemd or .wslconfig. |
@shigenobuokamoto yes seems so. Is there some documentation available how the wsl interact with the windows system in mirrored mode? I run into the next problem I started a container with nging -p80:80 but it is only reachable from wsl not from the windows host system. |
this is another issue in WSL(mirror mode): WSL cannot relay localhost accesses from Windows.
a temporary workaround for this is to exclude traffic from loopback0 (= pseudo-local loopback shared with Windows) from nat. i have prepared this response and IPv6 support for your reference. network-mirrored.service: [Unit]
Wants=network-pre.target
Before=network-pre.target shutdown.target
[Service]
User=root
ExecStart=/bin/sh -ec "\
nft add chain ip nat PREROUTING '{ type nat hook prerouting priority dstnat; policy accept; }';\
nft insert rule ip nat PREROUTING iif loopback0 counter accept comment mirrored;\
nft add table ip6 filter;\
nft add chain ip6 filter WSLOUTPUT '{type filter hook output priority filter; policy accept;}';\
nft add rule ip6 filter WSLOUTPUT counter meta mark set 0x00000001 comment mirrored;\
nft add table ip6 nat;\
nft add chain ip6 nat WSLPOSTROUTING '{type nat hook postrouting priority srcnat - 1; policy accept;}';\
nft add rule ip6 nat WSLPOSTROUTING 'oif "eth0" udp sport 1-65535 meta mark != 0x00000001 counter masquerade to :60600-60900' comment mirrored;\
nft add rule ip6 nat WSLPOSTROUTING 'oif "eth0" tcp sport 1-65535 meta mark != 0x00000001 counter masquerade to :60600-60900' comment mirrored;\
"
ExecStop=/bin/sh -ec '\
for chain in "ip nat PREROUTING" "ip6 filter WSLOUTPUT" "ip6 nat WSLPOSTROUTING";\
do\
handle=$(nft -a list chain $chain | sed -En "s/^.*comment \\"mirrored\\" # handle ([0-9]+)$/\\1/p");\
for n in $handle; do nft delete rule $chain handle $n; done;\
done;\
'
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target edited: in the case of usage:
|
@shigenobuokamoto soory seems I must reinstall my test system so it needs a bit to test. After last testing I can't get wsl to start even after complete remove and reinstall. It hangs on start. Logs attached |
Thank you. For some reason the ETL was completely empty. Did you start the trace before trying to open WSL? We have a new & better script for capturing traces: can you wsl --shutdown, start this trace by running the ps1, repro the issue once or twice, then stop the trace? https://github.com/microsoft/WSL/blob/master/diagnostics/collect-networking-logs.ps1 |
Thanks for reporting this. It looks like @shigenobuokamoto is correct - the rules we created for traffic exiting the Linux container only applied to IPv4 traffic, we didn't correctly make the corresponding IPv6 rules. I'm fixing that right now :) Thank you for reporting this! |
Thanks again. This should be fixed in the next WSL pre-release. |
closing since the issue is fixed |
Windows Version
Microsoft Windows [Version 10.0.22621.2428]
WSL Version
2.0.5
Are you using WSL 1 or WSL 2?
Kernel Version
5.15.133.1-microsoft-standard-WSL2
Distro Version
Ubuntu 22.04
Other Software
Docker Desktop Version: 4.24.2
Repro Steps
Expected Behavior
Container can reach ipv6 target, system nat outgoing ipv6 connection like ipv4
Actual Behavior
no ipv6 is reachable
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: