WLS2(ubuntu22.04)使用windows2的代理上网
1. 在wls2中,vim /etc/profile,添加如下配置后,source /etc/profile
```
export hostip=127.0.0.1
export socks_hostport=10800
export http_hostport=10800
alias proxy='
export https_proxy="https://${hostip}:${http_hostport}"
export http_proxy="http://${hostip}:${http_hostport}"
export ALL_PROXY="socks5://${hostip}:${socks_hostport}"
export all_proxy="socks5://${hostip}:${socks_hostport}"
'
alias unproxy='
unset ALL_PROXY
unset https_proxy
unset http_proxy
unset all_proxy
'
alias echoproxy='
echo $ALL_PROXY
echo $all_proxy
echo $https_proxy
echo $http_proxy
'
#end proxy
```
2. 想开代理,就在ubuntu中输入:proxy,想关闭就输入:unproxy,查看输入: echoproxy
3. 打开代理,测试,输入:
```
wget --no-cookie --no-check-certificate https://www.google.com
```
看到如下输出表示正常:
```
Connecting to 127.0.0.1:10800... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.2’
index.html.2 [ <=> ] 21.73K --.-KB/s in 0.1s
2024-09-13 10:23:17 (181 KB/s) - ‘index.html.2’ saved [22251]
```