Linux 防火墙启动失败问题

问题如下

`# systemctl start firewalld
Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details.`
firewall-cmd --reload
Traceback (most recent call last):
  File "/usr/bin/firewall-cmd", line 24, in 
    from gi.repository import GObject
ImportError: No module named gi.repository

有看到别的老哥说:

其实当输入 firewall-cmd 系列的命令的时候都会报错

原因

因为自己的linux上安装了多个python版本,在启动防火墙时,系统不知道指向了。

解决

修改firewalld文件头版本指向就可以,改成2.7(原先是python)

命令:

vi /usr/sbin/firewalld

Linux 防火墙启动失败问题_第1张图片
命令2:

vi /usr/bin/firewall-cmd

同样修改头文件指向为2.7版本~

Linux 防火墙启动失败问题_第2张图片

然后重启,本来以为这样就可以了,结果又报错,说是什么找不到bus:

Linux 防火墙启动失败问题_第3张图片
然后解决办法就是安装相关模块依赖:
执行命令:

yum install python-gobject -y
yum install python-firewall -y

然后安装成功后再次重启防火墙:
Linux 防火墙启动失败问题_第4张图片
启动成功了~

参考文章:

  1. https://blog.csdn.net/com_ma/article/details/78040517
  2. 2021年CentOS7关于Firewalld防火墙失效报错问题处理
  3. Linux——centos7防火墙重启失败

你可能感兴趣的:(Linux,linux,运维,服务器)