
wsl使用宿主机网络代理
WSL
Issues found on WSL
项目地址:https://gitcode.com/gh_mirrors/ws/WSL

·
问题
使用wsl宿主机网络代理,解决wsl的linux系统使用windows宿主机网络代理的问题
解决
- 首先获取宿主机IP
wsl中运行;
ip route |grep default|awk '{print $3}'
172.18.160.1
- 在wsl2的虚拟机中运行以下命令,若想一直开启宿主机代理,也可写入
vim ~/.zshrc
,然后使用source ~/.zshrc
,7890是宿主机网络代理端口
export https_proxy="http://172.18.160.1:7890"
export http_proxy="http://172.18.160.1:7890"
export all_proxy="sock5://172.18.160.1:7890"
export ALL_PROXY="sock5://172.18.160.1:7890"
- 若不想一直开启宿主机代理,设置命令开启或者关闭使用宿主机代理,在
vim ~/.zshrc
中写入,然后使用source ~/.zshrc
alias setp='export https_proxy="http://192.168.112.1:7890";export http_proxy="http://192.168.112.1:7890";export all_proxy="socks5://192.168.112.1:7890";export ALL_PROXY="socks5://192.168.112.1:7890";'
alias unsetp='unset https_proxy; unset http_proxy; unset all_proxy; unset ALL_PROXY;'
在终端输入setp即可开启代理, 输入unsetp 即可解除代理




Issues found on WSL
最近提交(Master分支:5 个月前 )
8c61f09e
* Add super user detection; a powershell approach is used
* use the 'id' command
* avoid stderr warning & wsl alias 17 天前
ae780d11
17 天前
更多推荐
所有评论(0)