升级到 Kubuntu 18.4 后,我在 git 或 ping 等命令行程序中遇到网络故障。
升级过程挂起了,我不得不重新启动笔记本电脑,但重新启动后,除了这一点之外,一切看起来都很好。
错误仅在 CLI 程序中可见。桌面程序似乎运行良好。
sebas@sebas-HP:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
sebas@sebas-HP:~$
sebas@sebas-HP:~$ ping google.com
connect: the network is unreachable
sebas@sebas-HP:~$ ping google.com ⏎
PING google.com (172.217.28.174) 56(84) bytes of data.
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=1 ttl=54 time=9.19 ms
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=2 ttl=54 time=10.0 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 9.199/9.634/10.069/0.435 ms
sebas@sebas-HP:~$ ping google.com
connect: the network is unreachable
sebas@sebas-HP:~$ ping google.com ⏎
PING google.com (172.217.28.174) 56(84) bytes of data.
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=1 ttl=54 time=17.4 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 17.406/17.406/17.406/0.000 ms
sebas@sebas-HP:~$ ping google.com
connect: the network is unreachable
sebas@sebas-HP:~$ ping google.com ⏎
PING google.com (172.217.28.174) 56(84) bytes of data.
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=1 ttl=54 time=9.34 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 9.348/9.348/9.348/0.000 ms
sebas@sebas-HP:~$ ping google.com
PING google.com (172.217.28.174) 56(84) bytes of data.
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=1 ttl=54 time=15.1 ms
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=2 ttl=54 time=10.0 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 10.032/12.577/15.122/2.545 ms
sebas@sebas-HP:~$ ping google.com
connect: the network is unreachable
sebas@sebas-HP:~$ ping google.com ⏎
PING google.com (172.217.28.174) 56(84) bytes of data.
64 bytes from eze03s29-in-f14.1e100.net (172.217.28.174): icmp_seq=1 ttl=54 time=11.1 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 11.169/11.169/11.169/0.000 ms
sebas@sebas-HP:~$ ping google.com
connect: the network is unreachable
有没有什么地方可以查找我可能遇到的错误配置?
答案1
我尝试了 user535733 建议的方法并进行了检查/var/log/syslog
。我发现了错误:
Dec 25 22:30:54 sebas-HP systemd-resolved[724]: Failed to open /etc/hosts: Permission denied
Dec 25 22:30:54 sebas-HP systemd-resolved[724]: Failed to start query: Permission denied
事情是这样的,我将 /etc/hosts 作为符号链接指向我常规用户主目录中的一个文件(因为我想在 git 中进行版本控制)。
$ ls -la | grep hosts
lrwxrwxrwx 1 root root 25 abr 26 2016 hosts -> /home/sebas/doc/prj/hosts
在我的 prj 文件夹中:
$ ls -la | grep hosts
-rwxr--r-- 1 sebas sebas 1758 oct 31 2017 hosts
不确定是符号链接还是权限导致了问题,但在上次系统升级之前从未失败过。
无论如何,将 /etc/hosts 恢复为常规文件可以解决问题。