Windows WSL 如何能連上區域網路內的電腦 (例如 ping)
2025-07-17
Windows WSL(Windows Subsystem for Linux)如何能連上區域網路內的電腦 (例如 ping)
(限 Windows 11 22H2+ 版本)
只要啟用 WSL2 的鏡像網路模式(mirrored networking mode) 即可
可以讓 WSL2 與 Windows 主機共享相同的網路介面
也就是 linux ip 會跟 Windows 相同,而不是 172.x.x.x(NAT模式)
1 檢查 wsl 版本 (需 2.0+ 以上 )
wsl --version
2 在 Windows 使用者目錄下建立 .wslconfig
notepad %USERPROFILE%.wslconfig
.wslconfig 檔案內容:
[wsl2]
networkingMode=mirrored
3 重新啟動 WSL:
wsl --shutdown
wsl
再測試看看,例如
ping 192.168.0.1
留言
相關文章