wsl2 debian新机配置

Clash代理配置

宿主机ipconfig获取宿主机ip地址,然后7890.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
proxy_on() {
export http_proxy="http://172.20.224.1:7890"
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
echo "proxy on"
}

proxy_off() {
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
echo "proxy off"
}

设置DNS

取消自动创建resolv.conf
1
2
3
# /etc/wsl.conf
[network]
generateResolvConf = false

文件不存在则创建。

删除软链接
1
rm /etc/resolv.conf
新建 /etc/resolv.conf
1
2
nameserver 8.8.8.8
nameserver 8.8.4.4

然后重启虚拟机。(wsl --shutdown

在不开启proxy的情况下能curl通 www.baidu.com即成功。

作者

ZRHan

发布于

2024-11-16

更新于

2025-04-17

许可协议