在 WSL 中获取 Windows 的 IP | LIXI.FUN
0%

在 WSL 中获取 Windows 的 IP

前置知识

wsl 中可以使用 powershell.exe

获取 Windows IP

以下命令是在 wsl 中执行的,不是 windows 中

1
powershell.exe -Command "(ipconfig)"

输出的结果和在 windows cmd 中执行 ipconfig 的结果是一样的

接下来就是用 grep 等工具筛选出需要的信息就可以了。

1
powershell.exe -Command "(ipconfig)" | grep IPv4 | grep 192 | awk '{print $14}'
觉得有收获就鼓励下作者吧