![Centos7 无法连接互联网,但本地 IP 和 ssh 可以工作](https://linux22.com/image/1460330/Centos7%20%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E4%BA%92%E8%81%94%E7%BD%91%EF%BC%8C%E4%BD%86%E6%9C%AC%E5%9C%B0%20IP%20%E5%92%8C%20ssh%20%E5%8F%AF%E4%BB%A5%E5%B7%A5%E4%BD%9C.png)
[如果太长可以从底部阅读]
您好,我之前有这个 Centos7,它通过静态 IP 的互联网连接运行良好。
问题始于我安装 GUI 时,首先我安装了 XFCE4(带 gdm),它运行良好,互联网也运行正常。只有 gdm 登录页面无法正常工作(带有光标的空白页),但事实并非如此。当我将 Mate(带 lightdm)安装到工作登录页面时,它影响了网络,因此我无法连接到互联网。但我仍然可以从其他计算机通过 SSH 连接到该机器。
ping 状态
[root@localhost ~]# ping 192.168.5.39 #local
PING 192.168.5.39 (192.168.5.39) 56(84) bytes of data.
64 bytes from 192.168.5.39: icmp_seq=1 ttl=64 time=0.200 ms
64 bytes from 192.168.5.39: icmp_seq=2 ttl=64 time=0.205 ms
64 bytes from 192.168.5.39: icmp_seq=3 ttl=64 time=0.191 ms
^C
--- 192.168.5.39 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.191/0.198/0.205/0.017 ms
[root@localhost ~]# ping 111.94.248.18 #-- google
connect: Network is unreachable
[root@localhost ~]#
这是 /etc/sysconfig/network-scripts/ifcfg-enp2s0 文件
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp2s0
TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp2s0"
#UUID="bb980114-13c0-4399-a310-9de54c5ddd75"
ONBOOT="yes"
HWADDR="FC:AA:14:80:C0:B5"
IPADDR0="192.168.5.20"
PREFIX0="24"
GATEWAY0="192.168.5.1"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
[root@localhost ~]#
这是 NetworkManager 服务状态
[root@localhost ~]# systemctl status NetworkManager.service
NetworkManager.service - Network Manager
Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
Active: failed (Result: start-limit) since Sel 2015-08-04 05:37:44 EDT; 17h ago
Process: 865 ExecStart=/usr/sbin/NetworkManager --no-daemon (code=exited, status=127)
Main PID: 865 (code=exited, status=127)
CGroup: /system.slice/NetworkManager.service
Agu 04 05:37:43 localhost.localdomain systemd[1]: Unit NetworkManager.service entered failed state.
Agu 04 05:37:44 localhost.localdomain systemd[1]: NetworkManager.service holdoff time over, scheduling restart.
Agu 04 05:37:44 localhost.localdomain systemd[1]: Stopping Network Manager...
Agu 04 05:37:44 localhost.localdomain systemd[1]: Starting Network Manager...
Agu 04 05:37:44 localhost.localdomain systemd[1]: NetworkManager.service start request repeated too quickly, refusing to start.
Agu 04 05:37:44 localhost.localdomain systemd[1]: Failed to start Network Manager.
Agu 04 05:37:44 localhost.localdomain systemd[1]: Unit NetworkManager.service entered failed state.
Agu 04 05:38:41 localhost.localdomain systemd[1]: Stopped Network Manager.
Agu 04 05:38:50 localhost.localdomain systemd[1]: Stopped Network Manager.
Agu 04 05:39:01 localhost.localdomain systemd[1]: Stopped Network Manager.
通过运行 nmcli 我得到了这个
[root@localhost ~]# nmcli dev status
nmcli: symbol lookup error: /lib64/libgudev-1.0.so.0: undefined symbol: g_type_class_adjust_private_offset
[root@localhost ~]#
这似乎是问题所在,我遇到了 duckduckgo&google,我猜他们在这里找到了解决方案https://access.redhat.com/solutions/1401813但只有订阅用户才能读取(可惜我没有任何可以负担订阅费用的服务器业务)。有人有办法解决这个问题吗?非常感谢
答案1
我意识到您可能已经摆脱了这个问题,但我还是发布了对我有用的解决方案,以防其他人遇到它。
我在 Centos 7 上遇到了同样的错误,并通过执行以下操作设法使 NetworkManager 再次运行:
sudo yum clean all
sudo yum install libgudev1-devel
然后照常启动 NetworkManager:
sudo service NetworkManager start