查看wsl2的ip
-> % ifconfig

开启服务,如nginx(配置端口为非80端口)
- 确保
wsl2的ip
:nginx配置中的端口
可以访问网站
cmd 获取主机ip
C:\WINDOWS\system32>ipconfig

cmd 管理员权限
- 映射
netsh interface portproxy add v4tov4 listenaddress=主机ip listenport=来个端口如8080 connectaddress=wsl2的ip connectport=nginx中配置的端口
- 查看
netsh interface portproxy show all
- 删除
netsh interface portproxy delete v4tov4 listenaddress=主机ip listenport=8080
防火墙新建端口规则:
- 防火墙->高级设置->入站规则->新建规则,新建一个端口规则

电脑打开移动热点

手机连上移动热点
手机访问
主机ip:8080
网友评论