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

55 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "WSL2 启动与网络配置指南"
type: source
tags: []
date: 2026-04-17
---
## Source File
- [[Home Office/WSL2 启动与网络配置指南.md]]
## Summary用中文描述
- 核心主题WSL2Windows Subsystem for Linux 2日常使用操作与网络配置
- 问题域WSL2 网络隔离导致 Windows 代理无法被 Linux 内部访问的痛点
- 方法/机制:
- 首次安装:`wsl --install` 一键安装
- 状态检查:`wsl -l -v` 查看版本
- 版本转换:`wsl --set-version <分发版> 2`
- 镜像网络模式:`.wslconfig` 配置 `networkingMode=mirrored` + `dnsTunneling=true`
- 手动代理:获取宿主机 IP 后设置 `http_proxy/https_proxy` 环境变量
- GitHub 加速:通过 `ghproxy.com` 反向代理下载
- 结论/价值:提供完整的 WSL2 从安装到生产可用的端到端操作指南
## Key Claims用中文描述
- WSL2 默认 NAT 模式导致 Windows localhost 代理无法被 WSL2 内部访问
- `.wslconfig``networkingMode=mirrored` 使 WSL2 与 Windows 共享网络堆栈,彻底解决代理镜像问题
- `ghproxy.com` 反向代理可将 GitHub 下载请求重定向至国内可访问节点
## Key Quotes
> "WSL2 默认使用 NAT 模式,常会出现 localhost 代理无法镜像或无法访问海外资源的情况" — 问题背景说明
> "这是最稳妥的方案,使 WSL2 与 Windows 共享网络堆栈" — 镜像模式推荐理由
> "始终先执行 `cd ~` 进入 Linux 原生家目录后再进行环境配置" — 文件权限最佳实践
## Key Concepts
- [[WSL2]]Windows Subsystem for Linux 2Windows 10/11 内置 Linux 虚拟机环境
- [[镜像网络模式Mirrored Networking]]WSL2 网络配置选项,使 WSL2 与 Windows 共享网络堆栈而非 NAT
- [[NAT 模式]]WSL2 默认网络模式WSL2 有独立 IP 与 Windows 隔离
- [[ghproxy]]ghproxy.comGitHub 反向代理加速服务
## Key Entities
- [[WSL2]]本文档主题Windows 内置 Linux 子系统第二版
- [[uv]]Python 包管理/安装工具,本文通过镜像地址安装
- [[Hermes Agent]]:本文通过 ghproxy 镜像安装的 AI Agent 产品
## Connections
- [[Install WSL]] ← depends_on ← [[WSL2 启动与网络配置指南]](安装指南为前置,配置指南为后续)
- [[WSL2 启动与网络配置指南]] ← extends ← [[Ubuntu Server科学上网]](均为 Linux 环境网络配置)
- [[WSL2 启动与网络配置指南]] ← uses ← [[ghproxy]]ghproxy 是解决 GitHub 下载的核心工具)
## Contradictions
- 与 [[Install WSL]] 视角差异:
- 冲突点Install WSL 聚焦安装过程,本文聚焦日常使用与网络配置
- 当前观点:本文将网络配置作为 WSL2 日常使用的重要组成部分
- 对方观点Install WSL 将安装与配置视为独立阶段
- 说明:两者互补,无本质冲突,安装指南完成后需参考本文完成网络配置