与你分享
互联网的方方面面

Windows10系统下配置WSL2自动走Clash代理

一、配置Clash

找到General > Allow LAN,打开开关。

二、配置防火墙

打开控制面板,找到系统和安全 > Windows Defender 防火墙 > 允许应用通过 Windows 防火墙,勾选上所有Clash相关的应用,包括但不限于Clash for Windows、clash-win64等。

三、配置WLS2

1、创建.proxy文件

touch ~/.proxy

2、添加一下内容

#!/bin/bash
hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890"
export http_proxy="http://${hostip}:7890"
export all_proxy="socks5://${hostip}:7890"

3、编辑.bashrc.zshrc文件,在文末添加一下内容

source ~/.proxy

四、测试

至此就配置完成了。可以使用以下命令测试下是否成功。

wget www.google.com

如果有类型的返回,则表示成功。

--2022-06-30 16:36:53--  http://www.google.com/
Connecting to 172.20.0.1:7890... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html                        [ <=>                                              ]  14.75K  --.-KB/s    in 0.06s

2022-06-30 16:36:53 (247 KB/s) - ‘index.html’ saved [15099]
赞(18)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《Windows10系统下配置WSL2自动走Clash代理》
文章链接:https://wph.im/199.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

相关推荐

  • 暂无文章