Category: wsl

1 Posts

Wsl2中访问win10的localhost网络代理
转:https://devdojo.com/mvnarendrareddy/access-windows-localhost-from-wsl2 grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}' 执行上面代码,得到一个ip,这个ip代替127.0.0.1或locahost即可。 参考链接:wsl2配置使用windows网络代理 参考链接2:设置代理脚本命令 总结: export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*') SOCKS5_PORT=10808 alias proxy=' export https_proxy="socks5://${hostip}:${SOCKS5_PORT}"; export http_proxy="socks5://${hostip}:${SOCKS5_PORT}"; echo -e "Acquire::http::Proxy \"http://${hostip}:${SOCKS5_PORT}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null; echo -e "Acquire::https::Proxy \"http://${hostip}:${SOCKS5_PORT}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null; ' alias unproxy=' unset https_proxy; unset http_proxy; unset all_proxy; sudo sed -i -e '/Acquire::http::Proxy/d' /etc/apt/apt.conf.d/proxy.conf; sudo sed -i -e '/Acquire::https::Proxy/d' /etc/apt/apt.conf.d/proxy.conf; ' 需要删除原文中: export all_proxy="socks5://${hostip}:1080" 这行,不然代理软件的日志中会出现: unknown Socks version: 67