在执行apt-get update命令的时候更新报错。

Err:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Could not resolve 'security.ubuntu.com'
Err:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
  Could not resolve 'cn.archive.ubuntu.com'
Err:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
  Could not resolve 'cn.archive.ubuntu.com'
Err:4 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
  Could not resolve 'cn.archive.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Could not resolve 'cn.archive.ubuntu.com'
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Could not resolve 'cn.archive.ubuntu.com'
W: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Could not resolve 'cn.archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@mec-PowerEdge-T40:~# vi /etc/resolv.conf 
root@mec-PowerEdge-T40:~# apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]        
Get:4 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]       
Get:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [48.9 kB]
Get:6 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [1,133 kB]     
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [57.1 kB]
Get:8 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1,713 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]  
Get:10 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [364 kB]
Get:11 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [295 kB]
Get:12 http://cn.archive.ubuntu.com/ubuntu bionic-updates/restricted i386 Packages [17.3 kB]
Get:13 http://cn.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [178 kB]
Get:14 http://cn.archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [24.0 kB]
Get:15 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe i386 Packages [1,542 kB]
Get:16 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,678 kB]
Get:17 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [353 kB]
Get:18 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [286 kB]
Get:19 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 48x48 Icons [214 kB]
Get:20 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe DEP-11 64x64 Icons [463 kB]
Get:21 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [31.7 kB]
Get:22 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse i386 Packages [13.0 kB]
Get:23 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [6,952 B]
Get:24 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:25 http://cn.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [9,288 B]
Fetched 8,683 kB in 4s (2,234 kB/s)                                   
Reading package lists... Done

解决办法:

修改DNS,编辑resolv.conf文件:原来的nameserver注释掉,加入下面2行即可

# vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

更新成功!!

 

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐