wsl联通外网

  1. 在C:\Users<你的用户名>下,新建.wslconfig文件

  2. 添加如下配置(具体配置参考官方文档):

    Settings apply across all Linux distros running on WSL 2

    [wsl2]

    Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB

    memory=8GB

    Sets the VM to use two virtual processors

    processors=8

    [experimental]
    autoMemoryReclaim=gradual # 开启自动回收内存,可在 gradual, dropcache, disabled 之间选择
    networkingMode=mirrored # 开启镜像网络
    dnsTunneling=true # 开启 DNS Tunneling
    firewall=true # 开启 Windows 防火墙
    autoProxy=true # 开启自动同步代理
    sparseVhd=true # 开启自动释放 WSL2 虚拟硬盘空间

  3. 重启 WSL 实例
    在 Windows PowerShell 中输入

powershell 复制代码
wsl --shutdown

在wsl环境里测试一下

powershell 复制代码
curl -v www.google.com

即为配置成功

相关推荐
tan77º1 小时前
【Linux网络编程】Socket - UDP
linux·服务器·网络·c++·udp
czhc11400756631 小时前
Linux 76 rsync
linux·运维·python
蓝易云2 小时前
Qt框架中connect()方法的ConnectionType参数使用说明 点击改变文章字体大小
linux·前端·后端
花落已飘3 小时前
多线程 vs 异步
linux·网络·系统架构
PanZonghui3 小时前
Centos项目部署之Nginx部署项目
linux·nginx
码出钞能力4 小时前
linux内核模块的查看
linux·运维·服务器
星辰云-5 小时前
# Linux Centos系统硬盘分区扩容
linux·运维·centos·磁盘扩容
聽雨2375 小时前
02每日简报20250704
linux·科技·金融·生活·社交电子·娱乐·媒体
Maki Winster6 小时前
Peek-Ubuntu上Gif录制工具-24.04LTS可装
linux·ubuntu·peek
Maki Winster7 小时前
在 Ubuntu 下配置 oh-my-posh —— 普通用户 + root 各自使用独立主题(共享可执行)
linux·运维·ubuntu