Centos7 重启之后无法连接

最近手贱重启了一台海外的openVZ架构VPS,系统版本是Centos7

执行完reboot后发现xshell 连不上了, 刚开始以为是防火墙的问题

通过官网提供的WebShell执行了 systemctl stop firewalld 发现依然连不上

想到有可能是装了iptables,执行命令 systemctl status iptables

发现竟然是active 状态,瞬间感觉找到问题了


1.png

执行命令:systemctl stop iptables, 将iptables 关闭,满心欢喜的用xshell尝试连接

等了半天,竟然提示超时!简直不可思议!

想起是国外的VPS 有可能开启了SElinux服务

原本想执行Vim /etc/selinux/config 将 SELINUX=enforcing 改为 SELINUX=disable

结果那WebShell 一执行Vim就闪退,尝试了几次后,使用setenforce 0 命令关闭了SELinux,心想这次应该能用xshell 连了吧

再次使用xshell 尝试连接, 发现竟然还是连接超时, 整个人都懵逼了

恢复清醒后,用之前python写的端口测试工具检测发现22端口竟然无法连接!

刚开始以为是sshd服务没开启,于是登录WebShell执行:systemctl start sshd

再次检测发现还是无法连接,与此同时检测了80端口发现也是无法连接,查看httpd 与 sshd 服务都是active 状态,

感觉还是防火墙拦截了,于是执行systemctl disable iptables firewalld 将防火墙服务都禁用了,再次reboot

使用WebShell登录确认iptables 和 firewalld 以及SELinux 状态都是disabled,用端口检测工具测试 80 , 22 端口都无法连接

用CMD Ping了下IP发现竟然ping 不通!登录WebShell ping 了下Youtube 竟然发回the Network is unreachable!

执行Ip addr 发现只有个127.0.0.1 感觉不太对劲, 执行命令systemctl status network 终于发现原来是network 服务没有跑起来

自信满满的执行命令: systemctl start network   结果Faild! Try Again, 结果还是 Faild!,  尝试了几次之后,开始慌了,

等了10多分钟,又试了几次network 服务还是没法 start , 不甘心的又reboot了一次,登录WebShell,执行systemctl start network  结果依旧是 Faild!

自己想不出解决方法,只能硬着头皮用蹩脚的英语拼凑了一封Email,

2.png

经过一天的等待终于收到了回复,

结果竟然是让我执行systemctl status network.service 查看错误信息!!!这相当于啥也没说.

3.png

因为英语水平太渣,就没再回复,过了一个星期左右,才想去自己有台VPS放在没开起来,再次登录WebShell

查看/etc/sysconfig/network-script/目录, 发现有3个ifcfg-文件,

4.png

网上看了各种资料, 关于如何修改ifconfig 什么 ifup , route add, 都执行了一遍, network 服务依旧Faild

因为WebShell 执行Vim闪退,没办法修改ifcfg配置文件,只能寻找其他解决方法

再次执行systemctl status network 希望从中能找到点线索

结果如下

[root@pphfXH-server /]# systemctl status network -l                                                         

* network.service – LSB: Bring up/down networking                                                           

   Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)                                  

   Active: failed (Result: exit-code) since Thu 2018-11-01 21:28:19 CST; 6min ago                           

     Docs: man:systemd-sysv-generator(8)                                                                    

  Process: 9253 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)                    

                                                                                                            

Nov 01 21:28:19 pphfXH-server network[9253]: RTNETLINK answers: File exists                                 

Nov 01 21:28:19 pphfXH-server network[9253]: RTNETLINK answers: File exists                                 

Nov 01 21:28:19 pphfXH-server network[9253]: RTNETLINK answers: File exists                                 

Nov 01 21:28:19 pphfXH-server network[9253]: RTNETLINK answers: File exists                                 

Nov 01 21:28:19 pphfXH-server network[9253]: RTNETLINK answers: File exists                                 

Nov 01 21:28:19 pphfXH-server systemd-sysctl[9446]: Failed to write ’16’ to ‘/proc/sys/kernel/sysrq': Permiss

ion denied                                                                                                  

Nov 01 21:28:19 pphfXH-server systemd[1]: network.service: control process exited, code=exited status=1     

Nov 01 21:28:19 pphfXH-server systemd[1]: Failed to start LSB: Bring up/down networking.                    

Nov 01 21:28:19 pphfXH-server systemd[1]: Unit network.service entered failed state.                        

Nov 01 21:28:19 pphfXH-server systemd[1]: network.service failed.                                           

Oct 28 21:28:28 pphfXH-server systemd[1]: Stopping LSB: Bring up/down networking…                         

Oct 28 21:28:29 pphfXH-server network[22742]: Shutting down interface venet0:  [  OK  ]                     

Oct 28 21:28:29 pphfXH-server network[22742]: Shutting down loopback interface:  [  OK  ]                   

Oct 28 21:28:29 pphfXH-server systemd[1]: Stopped LSB: Bring up/down networking.     

网上搜索了这几个Faild信息,终于找到了类似的问题: Failed to start LSB: Bring up/down networking.

在这里要感谢这位大佬写的CentOS7 Failed to start LSB: Bring up/down networking.解决方法( https://www.cnblogs.com/bonjov1/p/4323836.html )

造成network 服务无法开启的原因是Centos7虚拟机重启后,开启了NetworkManager服务

解决方法很简单,只需要执行:

systemctl stop NetworkManager

systemctl  disable NetworkManager

关闭NetworkManager 服务后再次执行 systemctl start network开启网络服务,终于不会再报错了

5.png

为此煞费苦心,以后要吸取教训,Linux 主机不要轻易Reboot, 除非你知道重启后系统是什么状态 !!!

还有一点就是, 不要贪便宜购买小商家提供的VPS主机, 太不靠谱了

Centos7 重启之后无法连接

转载请注明来源:幽幽过客_{Centos7 重启之后无法连接}