wsl2使用windows代理
使用 wsl2 克隆的过程中经常因为奇慢无比的速度而抓狂,查阅了相关资料之后,找出对自己有效的 wsl2 走 windows 代理的方法
一、前置
这里使用的是 clash for windows,注意需要打开允许局域网,打开的时候可能发现,鼠标悬停在开关上时,能看到 wsl 的 ip
二、具体实施
在 wsl 终端输入:
1 | cat /etc/resolv.conf |
可以查看 hostip:
1 | # This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: |
此后输入
1 | export https_proxy="http://${hostip}:7890" |
三、写成脚本
1 | #config.fish |
将上述内容写入 fish-shell 配置文件,使用 setproxy 打开代理,unsetproxy 关闭代理
四、检测成果
测试的方法有很多,比如:
1 | wget youtube.com |
或者
1 | w3m www.google.com |