wsl: add host DNS fallback to user-mode networking resolv.conf#28491
wsl: add host DNS fallback to user-mode networking resolv.conf#28491VedantMadane wants to merge 2 commits into
Conversation
|
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
|
@VedantMadane if you use an older version of gvproxy (like https://github.com/containers/gvisor-tap-vsock/releases/tag/v0.8.7 ) do you still face the same issue? There could be a regression there |
|
Thanks @lstocchi. I'll test with gvproxy v0.8.7 to see if the issue persists and report back. If it's a regression there, I'll update the PR with the findings. |
|
A friendly reminder that this PR had no activity for 30 days. |
|
@snejus @lstocchi Tested this on a podman 5.8.2 machine with user-mode networking. Injected the v0.8.7 gvproxy binary into both the main distro and the podman-net-usermode sidecar. Forced the pre-PR resolv.conf with just |
|
@VedantMadane just tried to see if i could replicate it but it seems to work as expected. I also tried with mirrored mode.
With gvproxy 0.8.9 it works fine without/with vpn I used gvproxy 0.8.9 as this is the new release which contains the fix for this kind of problems and it will be used by the next podman 5.8.3. Having a new machine should not be required but if you can clean your env up and try with a new machine + gvproxy 0.8.9 it would be great. If you modified the podman-net-usermode sidecar also remove it so it get recreated. Let us know. Thanks!! |
When user-mode networking is enabled, the main WSL distro gets a static /etc/resolv.conf pointing only to 192.168.127.1 (the gvproxy/gvforwarder DNS forwarder). If gvproxy cannot forward DNS queries — for example when a VPN connects and changes the host resolver — the main distro loses DNS entirely, while the podman-net-usermode distro (which uses WSL's auto-generated resolv.conf) continues to work fine. Append the host's actual nameservers from /mnt/wsl/resolv.conf as fallback entries after the user-mode networking nameserver. The Linux resolver tries nameservers in order, so gvproxy remains the primary path but the host DNS is available when the forwarder is unreachable. Fixes: podman-container-tools#28392 Signed-off-by: Vedant Madane <vedantmadane@gmail.com>
85c362d to
6439dd9
Compare
Problem
When user-mode networking is enabled on a WSL-backed podman machine,
createUserModeResolvConfwrites a static/etc/resolv.confcontaining onlynameserver 192.168.127.1(the gvproxy/gvforwarder address). Thepodman-net-usermodedistro keeps WSL's auto-generated resolv.conf and works fine, but the main machine distro hasgenerateResolvConf = falsein itswsl.conf, so its resolver never updates.When the host connects to a VPN (or any event that changes the host DNS), gvproxy may not forward queries to the new DNS servers. The main distro loses DNS while
podman-net-usermodecontinues working — exactly what #28392 describes.The workaround found by users is copying
/etc/resolv.conffrom thepodman-net-usermodedistro into the main distro. That works because the networking distro has the host's real DNS servers.Fix
After writing
nameserver 192.168.127.1to/etc/resolv.conf, also append the host's nameservers from/mnt/wsl/resolv.conf(the WSL-shared resolver file). The Linux resolver tries nameservers in order, so:/mnt/wsl/resolv.confis maintained by WSL and reflects current host DNSIf
/mnt/wsl/resolv.confdoesn't exist, the behavior is identical to before (only 192.168.127.1).Changes
createResolvScriptconstant — a small bash script that writes the user-mode nameserver then appends host nameservers from/mnt/wsl/resolv.confas fallback.createUserModeResolvConfnow pipes the script to bash instead of piping static content. Also fixes a minor style nit (return err→return nilafter the nil-check).Testing
Tested the script logic on a local WSL setup (Windows 11, WSL 2, mirrored networking). Verified that the resulting
/etc/resolv.confcontains both the 192.168.127.1 entry and the host DNS servers. With VPN connected, DNS resolves through the fallback servers when gvproxy is unavailable.Fixes: #28392
Signed-off-by: Vedant Madane vedantmadane@gmail.com