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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

烧饼博客

Ubuntu 24.04 Noble 升级 Ubuntu 26.04 Resolute Debian / Ubuntu 下使用 nginx-acme 自动签发并配置 SSL 证书 使用 acme.sh 配置 Let's Encrypt 签发的 IP 地址 SSL 证书 RDAP.SS - 基于 RDAP 协议的 Whois 查询网站 Debian 使用 extrepo 配置第三方软件源 升级 Debian 后 GitLab PostgreSQL 无法启动的解决方法 Debian 12 Bookworm 升级 Debian 13 Trixie Ubuntu 22.04 Jammy 升级 Ubuntu 24.04 Noble Docker 安装 FreshRSS 教程 Docker 安装 Shlink 自建短网址 Debian 安装 Nextcloud 服务端 Debian 双栈网络时开启 IPv4 优先 Debian / Ubuntu 使用源安装 LAMP 教程 Debian / Ubuntu 使用源安装 LEMP 教程
WSL 2 使用 Docker 桥接模式网络访问 HTTPS 超时的解决方法
Showfom · 2026-01-21 · via 烧饼博客
WSL 2 使用 Docker 桥接模式网络访问 HTTPS 超时的解决方法

本文介绍在 WSL 2 中使用 Docker 的桥接模式(bridge network)访问 HTTPS 时出现超时问题的解决方法。

最近一直在 Windows 下使用基于 WSL 2 的 Debian 进行开发。许多场景下需要使用 Docker 构建镜像,但过程中遇到一个奇怪的问题,在 Docker 容器内部访问 HTTP 站点时一切正常:

$ docker run --rm curlimages/curl time curl -s http://ip.gs
192.0.2.2
real    0m 0.02s
user    0m 0.00s
sys     0m 0.00s

一旦切换为 HTTPS,访问就会明显变慢,并且有一定概率出现超时:

$ docker run --rm curlimages/curl time curl -s https://ip.gs
192.0.2.2
real    0m 6.52s
user    0m 0.00s
sys     0m 0.00s

然而,如果将 Docker 切换到 Host 模式(--network=host),访问又恢复正常:

$ docker run --rm --network=host curlimages/curl time curl -s https://ip.gs
192.2.0.2
real    0m 0.28s
user    0m 0.00s
sys     0m 0.00s

在排查了 WSL 2 的 Debian 系统配置后,最终请教 ChatGPT 得到结论:

Path MTU 与防火墙流量检查(inspection)不兼容导致问题

解决方法很简单:将 WSL 2 虚拟网络的 MTU 下调为 1400 即可。

#1、添加 Docker 配置

在 WSL 2 的系统里,使用 root 用户修改 /etc/docker/daemon.json 文件:

{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "20m",
        "max-file": "3"
    },
    "mtu": 1400,
    "dns": [
      "8.8.8.8",
      "1.1.1.1"
    ]
}

其中 "mtu": 1400, 是关键配置。

然后在 Windows 下把 WSL 2 关闭:

#2、修改 WSL 2 网卡配置

在 Windows 下使用管理员身份运行 Powershell,检查网卡名称:

PS C:\Users\showfom> Get-NetAdapter | Where-Object { $_.Name -like "*WSL*" }

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
vEthernet (WSL (Hyper-V … Hyper-V Virtual Ethernet Adapter #3          41 Up           12-34-56-78-AB-CD        10 Gbps

PS C:\Users\showfom> Get-NetAdapter | Format-Table -AutoSize

Name                               InterfaceDescription                      ifIndex Status       MacAddress        Lin
                                                                                                                    kSp
                                                                                                                    eed
----                               --------------------                      ------- ------       ----------        ---
vEthernet (Default Switch)         Hyper-V Virtual Ethernet Adapter               35 Up           12-34-56-78-AB-ABps
vEthernet (WSL (Hyper-V firewall)) Hyper-V Virtual Ethernet Adapter #3            41 Up           12-34-56-78-AB-CD …ps

输出可以看到完整名称为 vEthernet (WSL (Hyper-V firewall)),然后为其设置 MTU:

netsh interface ipv4 set subinterface "vEthernet (WSL (Hyper-V firewall))" mtu=1400 store=persistent

出现 Ok. 字样即代表设置成功。

#3、测试 WSL 2 中的 Docker 网络

然后重新运行 WSL 2 虚拟机:

再次测试:

$ docker run --rm curlimages/curl time curl -s https://ip.gs
192.0.2.2
real    0m 0.28s
user    0m 0.00s
sys     0m 0.00s

问题已完美解决,可以继续愉快地 Vibe Coding 了! ★,°:.☆( ̄▽ ̄)/$:.°★