发现防火墙无法启动
6月 13 23:47:40 localhost.localdomain systemd[1]: Failed to start firewalld - dynamic firewall daemon.
# 原因一:
在网上查了资料,说是由于系统里面安装的 python 版本原因。/usr/sbin/firewalld 文件头部的 python 版本和安装的 python 版本不一致导致的。
1. 先查看 linux 系统的 Python 版本
[root@localhost xinetd.d]# python --version
Python 2.7.5
1 查看 firewalld 在那个路径下
[root@localhost xinetd.d]# which firewalld
/usr/sbin/firewalld
2 查看 firewalld 文件和 firewalld-cmd 文件头是否一致且与 Python 一致,如果不一致,需要改成与 Python 版本一致。一般网上说是改成 #!/usr/bin/python2.7 -Es,本机实验发现,都改成 2 也行。
[root@localhost xinetd.d]# head -n 10 /usr/sbin/firewalld
#!/usr/bin/python2 -Es
# -*- coding: utf-8 -*-
[root@localhost xinetd.d]# head -n 10 /usr/bin/firewall-cmd
#!/usr/bin/python2 -Es
# -*- coding: utf-8 -*-
# 原因二:
如果不是安装 Python 的话,那估计是下列问题了。输入下面的命令就能解决。
[root@localhost xinetd.d]# systemctl stop firewalld
[root@localhost xinetd.d]# pkill -f firewalld
[root@localhost xinetd.d]# systemctl start firewalld
# 总结:
如果不是安装 Python,那么一般都是 firewalld 的进程问题。
firewalld 的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
查看开放的端口:firewall-cmd --list-ports
添加端口:firewall-cmd --add-port=8080/tcp --permanent (–permanent 永久生效,没有此参数重启后失效)
. 防火墙重新加载:firewall-cmd --reload
参考网址:
https://blog.csdn.net/lanju2012/article/details/79757292
https://blog.csdn.net/qq_27751535/article/details/89633138
https://blog.csdn.net/crynono/article/details/76132611