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
酸爽