WSL2 设置代理

  1. 打开 Clash 的 Allow LAN
  2. ~/.bashrc 最下方添加
    host_ip=$(cat /etc/resolv.conf |grep "nameserver" |cut -f 2 -d " ")
    alias setproxy="export all_proxy=http://$host_ip:7890;export http_proxy=http://$host_ip:7890;export https_proxy=http://$host_ip:7890;"
    alias unsetproxy="unset all_proxy;unset http_proxy;unset https_proxy;"
    
  3. 使用 setproxy 启动代理, unsetproxy 关闭代理

参考文章 : 为 WSL2 一键设置代理

原文地址:https://www.cnblogs.com/CodeAndMoe/p/15376790.html