WSL2使用Windows代理


Windows 原生运行Linux如何自由访问互联网 WSL2 使用 Clash for Windows做代理 – V2方圆 (v2fy.com)

hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
alias setp='export https_proxy="http://${hostip}:7890";export http_proxy="http://${hostip}:7890";export all_proxy="socks5://${hostip}:7890";export ALL_PROXY="socks5://${hostip}:7890";'
alias unsetp='unset https_proxy; unset http_proxy; unset all_proxy; unset ALL_PROXY;'

使用时发现在执行sudo命令时,代理失效,这是因为代理配置只对当前用户生效,若想对root用户生效,需要切换到root用户,重新设置一下。


文章作者: Hiper
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Hiper !
  目录