wsl2 安装后用 wifi 共享是能联网,问题出在公司网络限制 wsl2 IP 访问网络,但是主机可以上网。
解决办法,在主机用 nginx 设置代理,可能需要开端口权限
server {
listen 9000;
server_name localhost;
location /ubuntu/ {
# 阿里源镜像地址
proxy_pass https://mirrors.aliyun.com/ubuntu/; # 前端地址和端口
}
}
/etc/apt/sources.list
# 阿里源镜像地址
deb http://192.168.5.116:9000/ubuntu/ focal main restricted universe multiverse
deb http://192.168.5.116:9000/ubuntu/ focal-security main restricted universe multiverse
deb http://192.168.5.116:9000/ubuntu/ focal-updates main restricted universe multiverse
deb http://192.168.5.116:9000/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://192.168.5.116:9000/ubuntu/ focal main restricted universe multiverse
deb-src http://192.168.5.116:9000/ubuntu/ focal-security main restricted universe multiverse
deb-src http://192.168.5.116:9000/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://192.168.5.116:9000/ubuntu/ focal-backports main restricted universe multiverse
sudo apt update

酸爽