Files
nexus/wiki/sources/wsl2-启动与网络配置指南.md
2026-04-24 00:03:01 +08:00

2.5 KiB
Raw Blame History

title, type, tags, date
title type tags date
WSL2 启动与网络配置指南 source
2026-04-17

Source File

Summary用中文描述

  • 核心主题WSL2Windows Subsystem for Linux 2的安装启动与网络配置实操指南
  • 问题域Windows 环境下 Linux 开发环境搭建,重点解决 WSL2 网络隔离导致的 GitHub/海外资源访问障碍
  • 方法/机制:① wsl --install 快速安装;② .wslconfig 启用镜像网络模式mirrored mode实现 WSL2 与 Windows 共享网络堆栈;③ 终端代理环境变量手动配置;④ ghproxy.com 反向代理绕过网络限制
  • 结论/价值:提供从零安装到生产可用的完整 WSL2 配置路径,镜像网络模式是最稳妥的解决方案,避免 NAT 模式下的 localhost 代理失效问题

Key Claims用中文描述

  • WSL2 默认使用 NAT 模式,导致 Windows 宿主机 localhost 代理无法被 WSL2 内部正确访问,这是 GitHub/海外资源连接失败的根本原因
  • .wslconfig 中设置 networkingMode=mirrored + dnsTunneling=true + autoProxy=true 可使 WSL2 与 Windows 共享网络堆栈,是解决网络问题的推荐方案
  • 使用 ghproxy.com 反向代理可绕过 GitHub 访问限制,适用于 uv 安装器、Hermes Agent 等工具的下载场景

Key Quotes

"WSL2 默认使用 NAT 模式,常会出现'localhost 代理无法镜像'或无法访问海外资源的情况。" — 背景说明 "在 PowerShell 执行 wsl --shutdown 后重启 WSL。" — 镜像模式生效操作

Key Concepts

  • WSL2Windows Subsystem for Linux 2Windows 10/11 内置的 Linux 虚拟机环境,默认使用 NAT 网络模式
  • 镜像网络模式Mirrored Network ModeWSL2 与 Windows 共享网络堆栈的配置模式,使 WSL2 能直接访问 Windows 代理
  • NAT模式WSL2 默认网络模式WSL2 拥有独立 IPlocalhost 代理不可用
  • ghproxyghproxy.com反向代理服务将 GitHub 资源 URL 替换为代理地址以绕过网络限制

Key Entities

  • UbuntuWSL2 默认安装的 Linux 分发版
  • Windows宿主操作系统WSL2 运行其上
  • PowerShellWindows 命令行环境,用于执行 wsl 管理命令

Connections

Contradictions

  • (无已知冲突)