查看: 79|回覆: 1

[Debian] wsl中debian无法连接到源

[複製鏈接]

2

主題

0

回帖

0

積分

热心网友

金币
0
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2012-6-4
發表於 2021-5-31 06:21:00 | 顯示全部樓層 |閲讀模式

使用wsl中的debian10更新时,出现如下错误:

admin@DESKTOP:~$ sudo apt update
Err:1 http://deb.debian.org/debian buster InRelease
  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to deb.debian.org:80 (127.167.1.232). - connect (111: Connection refused) Cannot initiate the connection to deb.debian.org:80 (fd00:696e:6974:6578::4f:1e9). - connect (101: Network is unreachable)
Err:2 http://deb.debian.org/debian buster-updates InRelease
  Cannot initiate the connection to deb.debian.org:80 (fd00:696e:6974:6578::4f:1e9). - connect (101: Network is unreachable)
Err:3 http://ftp.debian.org/debian buster-backports InRelease
  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to ftp.debian.org:80 (127.167.2.112). - connect (111: Connection refused) Cannot initiate the connection
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /eto ftp.debian.org:80 (fd00:696e:6974:6578::4f:271). - connect (101: Network is unreachable)
Err:4 http://security.debian.org/debian-security buster/updates InRelease
  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to security.debian.org:80 (127.167.1.234). - connect (111: Connection refused) Cannot initiate the connection to security.debian.org:80 (fd00:696e:6974:6578::4f:1eb). - connect (101: Network is unreachable)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to deb.debian.org:80 (127.167.1.232). - connect (111: Connection refused) Cannot initiate the connection to deb.debian.org:80 (fd00:696e:6974:6578::4f:1e9). - connect (101: Network is unreachable)
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease  Cannot initiate the connection to deb.debian.org:80 (fd00:696e:6974:6578::4f:1e9). - connect (101: Network is unreachable)
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to security.debian.org:80 (127.167.1.234). - connect (111: Connection refused) Cannot initiate the connection to security.debian.org:80 (fd00:696e:6974:6578::4f:1eb). - connect (101: Network is unreachable)
W: Failed to fetch http://ftp.debian.org/debian/dists/buster-backports/InRelease  Could not connect to debian.map.fastlydns.net:80 (127.167.1.230). - connect (111: Connection refused) Cannot initiate the connection to debian.map.fastlydns.net:80 (fd00:696e:6974:6578::4f:1e7). - connect (101: Network is unreachable) Could not connect to ftp.debian.org:80 (127.167.2.112). - connect (111: Connection refused) Cannot initiate the connection to ftp.debian.org:80 (fd00:696e:6974:6578::4f:271). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

经过一番查询和乱搞下,发现修改dns服务器后就好了

sudo vi /etc/resolv.conf

把nameserver换成 8.8.8.8 和 8.8.4.4

在重新启动一下网络:

sudo /etc/init.d/networking restart

在更新就没有错误了。



来源:https://www.cnblogs.com/litifeng/p/14829865.html
回覆

使用道具 舉報

0

主題

1383

回帖

8419

積分

琼殿精英

金币
7036
閲讀權限
220
精華
0
威望
0
贡献
0
在線時間
0 小時
註冊時間
2011-10-11
發表於 3 小時前 | 顯示全部樓層
LZ的问题已经解决了,真是太好了!给你顶一个~

其实WSL的网络问题确实挺烦人的,特别是DNS这块。你用的这个方法很有效,不过有一点要提醒一下:

WSL每次重启后可能会重置/etc/resolv.conf文件,如果以后再遇到这个问题,可以考虑以下几种永久解决方案:

1. 创建/etc/wsl.conf文件,添加以下内容防止WSL自动重置DNS:
  1. [network]
  2. generateResolvConf = false
複製代碼

2. 或者使用国内的Debian镜像源,比如清华源、阿里源等,访问速度更快也不容易被墙:
  1. deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
  2. deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
  3. deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
複製代碼

希望这些信息对以后遇到同样问题的同学有帮助!感谢LZ分享解决方案~
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部