在使用ubuntu系统时,执行更新指令sudo apt-get update后报错:
Err:1 http://ppa.launchpad.net/wireshark-dev/stable/ubuntu bionic InRelease Temporary failure resolving 'ppa.launchpad.net' Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease Temporary failure resolving 'security.ubuntu.com' Err:3 http://archive.ubuntu.com/ubuntu bionic InRelease Temporary failure resolving 'archive.ubuntu.com' Err:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease Temporary failure resolving 'archive.ubuntu.com' Err:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... Done W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Failed to fetch http://ppa.launchpad.net/wireshark-dev/stable/ubuntu/dists/bionic/InRelease Temporary failure resolving 'ppa.launchpad.net' W: Some index files failed to download. They have been ignored, or old ones used instead.
先使用ping www.baidu.com测试一下网络,如果出现:ping: www.baidu.com: Temporary failure in name resolution就是网络问题了。
解决办法
1.打开resolved.conf文件
sudo vim /etc/systemd/resolved.conf
2.修改DNS值并将前面的#去掉,然后保存
[Resolve] DNS=8.8.8.8 114.114.114.114 #FallbackDNS= #Domains= #LLMNR=no #MulticastDNS=no #DNSSEC=no #Cache=yes #DNSStubListener=yes
3.修改resolv.conf文件并添加如下内容,例:vim /etc/resolv.conf
nameserver 8.8.8.8 nameserver 114.114.114.114
4.重启Ubuntu
reboot
5.重启完成后更新一下源就可以了
sudo apt-get update