🐠 WSL2代理
# WSL2代理
## 使用允许局域网连入功能
[WSL2访问宿主机](https://hellodk.cn/post/703)
## 在WSL2里部署Clash
[Clash for Linux](https://ikuuu.eu/user/tutorial?os=linux&client=clash)
## clash dashboard容器
可以使用`clash dashboard`容器进行配置
```
docker pull haishanh/yacd
docker run -p 1234:80 -d haishanh/yacd
```
# WSL2配置
## set_proxy
```
ip_host=$(cat /etc/resolv.conf | grep 'nameserver' | awk '{print $2}')
export http_proxy="http://${ip_host}:7890"
export https_proxy="http://${ip_host}:7890"
export HTTP_PROXY="http://${ip_host}:7890"
export HTTPS_PROXY="http://${ip_host}:7890"
export all_proxy="socks5://${ip_host}:7891"
export ALL_PROXY="socks5://${ip_host}:7891"
echo "http_proxy is ${http_proxy}"
git config --global http.proxy http://${ip_host}:7890
echo "git proxy has set"
```
## reset_proxy
```
export http_proxy=""
export https_proxy=""
export all_proxy=""
export ALL_PROXY=""
echo "http_proxy is ${http_proxy}"
git config --global --unset http.proxy
echo "git is unset"
```
## set_proxy_linux
```
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export all_proxy="socks5://127.0.0.1:7891"
export ALL_PROXY="socks5://127.0.0.1:7891"
export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
echo "http_proxy is ${http_proxy}"
git config --global http.proxy http://127.0.0.1:7890
echo "git proxy has set"
```
## 测试代理是否可用
```
wget -e use_proxy=yes -e http_proxy=http://10.214.122.44:7890 www.google.com
```
## 经验之谈
下载github上的代码的时候WSL2的那个IP地址是可以的(网关),下载Google网页的时候,主机的IP地址也是可以的。难道是两个都行?
通过-c的方式配置参数会出现不可名状的错误,舍弃
ThinkPad这台电脑无法使用WSL2的那个IP
外星人那台却是可以的,真是奇了怪了
ThinkPad可以使用主机的那个IP,经过全局配置之后就快的飞起。