linux防火墙启动失败,Centos 7防火墙启动失败

突然之间发现centos 7 的防火墙无法启动,且firewall-cmd命令运行报错:

防火墙启动报错如下:

[root@localhost firewalld]# systemctl start firewalld.service

Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details.

[root@localhost firewalld]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

Active: failed (Result: exit-code) since 三 2020-01-08 10:43:48 CST; 10s ago

Docs: man:firewalld(1)

Process: 29630 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=127)

Main PID: 29630 (code=exited, status=127)

firewall-cmd命令运行报错如下:

[root@localhost yangl]# firewall-cmd

Traceback (most recent call last):

File "/usr/bin/firewall-cmd", line 24, in

from gi.repository import GObject

ImportError: No module named gi.repository

究其原因是由于使用了自定义安装的python,并将自己安装的python作为默认python导致(此外,将系统默认的python升级为python3也可能会出现类似问题),因此只需将firewalld和firewall-cmd第一行调用的python改为系统的python即可解决。

我的python链接方式如下:

[root@localhost yangl]# cd /usr/bin/

[root@localhost bin]# ll python*

lrwxrwxrwx. 1 root root 16 9月 28 2018 python -> /usr/bin/python2

lrwxrwxrwx. 1 root root 39 9月 28 2018 python2 -> /share/soft/python-2.7.15/bin/python2.7

-rwxr-xr-x. 1 root root 7216 7月 13 2018 python2.7 #系统的python

lrwxrwxrwx. 1 root root 9 9月 28 2018 python2_old -> python2.7

lrwxrwxrwx. 1 root root 36 3月 7 2018 python3 -> /share/soft/python-3.6.4/bin/python3

lrwxrwxrwx. 1 root root 7 9月 28 2018 python_old -> python2

因此,只需vi打开/usr/sbin/firewalld 和/usr/bin/firewall-cmd,将其中的第一行由#!/usr/bin/python -Es 改为#!/usr/bin/python2.7 -Es 即可!

引用:

https://blog.csdn.net/cpongo1/article/details/89547129

https://www.cnblogs.com/wuzaipei/p/10830727.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值