在WSL应用Cargo时,会有须要用到外网的状况。假如咱们在windows开了一个端口为10809的HTTP代理。咱们的指标是让WSL中的cargo build
应用到这个代理。
查看WSL拜访windows的IP地址
cat /etc/resolv.conf
能够看到相似的输入
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:# [network]# generateResolvConf = falsenameserver 172.22.96.1
其中的nameserver就是windows的IP地址,咱们能够将代理设置为http://172.22.96.1:10809
,这样WSL就能够应用到架设在windows里的代理服务。
要留神到这个IP地址是不是会产生扭转,因为WSL2和代理服务不兼容的BUG,咱们常常须要应用netsh winsock reset
重置网络,这时候这个IP地址可能会发生变化,导致代理设置生效
失去IP地址后,关上~/.cargo/config.toml
写入以下字段
[http]debug = trueproxy = "172.22.96.1:10809"