惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Latest
Security Latest
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MyScale Blog
MyScale Blog
T
Tor Project blog
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
P
Privacy & Cybersecurity Law Blog
MongoDB | Blog
MongoDB | Blog
Simon Willison's Weblog
Simon Willison's Weblog
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
小众软件
小众软件
G
GRAHAM CLULEY
P
Privacy International News Feed
AWS News Blog
AWS News Blog
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
人人都是产品经理
人人都是产品经理
S
Schneier on Security
Scott Helme
Scott Helme
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
T
The Exploit Database - CXSecurity.com
Recent Announcements
Recent Announcements
E
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
U
Unit 42
The Register - Security
The Register - Security
S
Securelist
Martin Fowler
Martin Fowler
Project Zero
Project Zero
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog

博客园 - DHclly

Aspose.Words 合并单元格的原理、配置方式、代码示例以及常见误区 Gpustack 运行一段时间后出现 Failed to initialize NVML: Unknown Error 解决办法 wps dispimg python 解析实现参考 NVIDIA GPU 计算能力( compute capability,SM version)兼容性查询 Amazon S3 Tools:S3cmd 介绍 nginx 根路径同时代理 http ws sse 三种请求 在 X86_64(amd64) 平台上的docker支持打包跨平台的镜像(如arm64) 以图搜图功能介绍 docker 容器调试技巧 open ai sdk 的额外请求头说明 x-stainless 大模型常见的概念 创建软连接的几种方式 基于node.js 的 web server 实现 对个人的警醒 jQuery对象与DOM对象之间的转换方法 【BUG】浏览器控制台提示:net::ERR_INVALID_CHUNKED_ENCODING 200 (OK) 的解决思路 实用浏览器脚本 关于Lambda表达式(箭头函数)的get属性访问器和常规的get属性访问器的差异 转换字符串为二进制编码字符串
wsl 和win主机互相访问
DHclly · 2024-10-31 · via 博客园 - DHclly

参考文档

windows 访问

# windows 以太网 ip 地址
(curl http://192.168.0.100:8090/api/Tool/DateTime).Content
# window 在 WSL 上的 ip 地址
(curl http://172.26.192.1:8090/api/Tool/DateTime).Content
# windows localhost
(curl http://localhost:8090/api/Tool/DateTime).Content
# windows ipv4 127.0.0.1
(curl http://127.0.0.1:8090/api/Tool/DateTime).Content
# windows ipv6 127.0.0.1
(curl http://[::1]:8090/api/Tool/DateTime).Content
# windows wsl unbuntu系统的 ip 地址
(curl http://172.26.198.196:8090/api/Tool/DateTime).Content

# wsl 中查询windows访问wsl的ip地址
hostname -I
172.26.198.196

wsl unbuntu访问

# linux ubuntu localhost
curl -s http://localhost:8090/api/Tool/DateTime | sed '$a\'
# linux ubuntu ipv4 127.0.0.1
curl -s http://127.0.0.1:8090/api/Tool/DateTime | sed '$a\'
# linux ubuntu ipv6 127.0.0.1
curl -s http://[::1]:8090/api/Tool/DateTime | sed '$a\'
# linux ubuntu eth0网卡上的 ip 地址
curl -s http://172.26.198.196:8090/api/Tool/DateTime | sed '$a\'
# host.docker.internal 地址
curl -s http://host.docker.internal:8090/api/Tool/DateTime | sed '$a\'
curl -s http://gateway.docker.internal:8090/api/Tool/DateTime | sed '$a\'
curl -s http://kubernetes.docker.internal:8090/api/Tool/DateTime | sed '$a\'
# window 在 WSL 上的 ip 地址
curl -s http://172.26.192.1:8090/api/Tool/DateTime | sed '$a\'
# windows 以太网 ip 地址(无法访问)
curl -s http://192.168.0.100:8090/api/Tool/DateTime | sed '$a\'

# wsl 中查询wsl访问windows的ip地址
ip route show | grep -i default | awk '{ print $3}'
172.26.192.1

转发 wsl 服务端口到 windows,可通过windows 外部 ip 访问

即除了127.0.0.1外的其他 ip 地址都可以访问。

hostname -I
172.26.198.196

netsh interface portproxy add v4tov4 listenport=<yourPortToForward> listenaddress=0.0.0.0 connectport=<yourPortToConnectToInWSL> connectaddress=(wsl hostname -I)

netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=172.26.198.196
netsh interface portproxy delete v4tov4 listenport=80 listenaddress=0.0.0.0

netsh interface portproxy add v4tov4 listenport=65535 listenaddress=0.0.0.0 connectport=65535 connectaddress=172.26.198.196

netsh interface portproxy show all

windows 防火墙允许 wsl 访问 windows 服务

New-NetFirewallRule -DisplayName "WSL" -Direction Inbound  -InterfaceAlias "vEthernet (WSL)"  -Action Allow

Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"