📜  从 wsl2 访问 wiindows 主机 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:55.279000             🧑  作者: Mango

代码示例1
# You should run the following command in a powershell run as administrator:
New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow
# Then in WSL 2 add this line to your .profile
export hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
# Then use 'hostip:' to access any service runnin on your windows host from inside WSL 2