wsl和win无法互相ping
2025-12-10
Linux运维
00

win:

js
展开代码
C:\Users\Administrator\.wslconfig

win写这个文件为:

js
展开代码
[wsl2] networkingMode=mirrored dnsTunneling=true firewall=false autoProxy=true

win重启,然后ps关闭防火墙:

js
展开代码
# 允许 ICMPv4 入站流量(针对 ping) New-NetFirewallRule -DisplayName "WSL Ping Allow" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow -Protocol ICMPv4

wsl:

js
展开代码
cc@DESKTOP-564RG57:~$ cat /etc/resolv.conf # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 172.21.160.1

wsl ping 这个nameserver。

如果对你有用的话,可以打赏哦
打赏
ali pay
wechat pay

本文作者:Dong

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!