在Windows下使用podman时,通过curl访问内部服务失败:
PS C:\Users\<USER>> podman run docker.io/nicolaka/netshoot curl https://<INTERNAL_IP_OR_HOST>:6443/version --insecure
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (35) Recv failure: Connection reset by peer
当直接在 podmans WSL 发行版中触发相同的内部curl 请求时,一切正常:
PS C:\Users\<USER>> wsl -d podman-machine-default
You will be automatically entered into a nested process namespace where
systemd is running. If you need to access the parent namespace, hit ctrl-d
or type exit. This also means to log out you need to exit twice.
[<USER>@<HOSTNAME> ~]$ podman run docker.io/nicolaka/netshoot curl https://<INTERNAL_IP_OR_HOST>:6443/version --insecure
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "Unauthorized",
"reason": "Unauthorized",
"code": 401
100 157 100 157 0 0 2474 0 --:--:-- --:--:-- --:--:-- 2492
直接从 Windows 下运行的容器进行 ping 工作正常(curl 失败):
PS C:\Users\<USER>> podman run docker.io/nicolaka/netshoot ping <INTERNAL_IP_OR_HOSTNAME>
PING <INTERNAL_IP_OR_HOSTNAME> (<INTERNAL_IP_OR_HOSTNAME>) 56(84) bytes of data.
64 bytes from <INTERNAL_IP_OR_HOSTNAME>: icmp_seq=1 ttl=60 time=12.2 ms
通过 podman 从 Windows 访问其他外部服务工作正常:
PS C:\Users\<USER>> podman run docker.io/nicolaka/netshoot curl https://google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
100 220 100 220 0 0 1524 0 --:--:-- --:--:-- --:--:-- 1527
有人见过类似的行为吗?
环境
适应
添加了我的内部域的 DNS 服务器以启用内部主机名解析
因此,可以从 Windows 计算机以及 WSL 内部解析内部主机名。这不是DNS解析问题!
VPN 断开连接后,我可以直接访问内部服务,一切正常。
更新
Windows 中启动容器与 WSL 中启动容器的区别似乎在于数据包是碎片化的。需要在这个方向进一步研究。这是 Wireshark 跟踪:
最终解决方案
问题如编辑部分中所示的 mtu 大小。 Podman 网络支持 MTU 大小的配置:
podman network create podman-lower-mtu --disable-dns --opt mtu=1300