首先CentOS7.5的防火墙改为了firewall-cmd,而非iptables
1、防火墙的使用:
首先使用netstat -tunlp命令来查看当前已经在使用的端口,如下图所示:

2、使用firewall-cmd --list-ports命令来查看已经添加到防火墙的端口,如下图所示:

3、添加一个端口:firewall-cmd --permanent --add-port=4202/tcp --permanent,其中--permanent表示永久性的,注意添加后要执行:firewall-cmd --reload进行重新载入,
4、重启防火墙:service firewalld restart

5、查看防火墙状态:firewall-cmd --state

6、service firewalld start 开启防火墙
7、service firewalld stop 关闭防火墙
8、systemctl disable firewalld 关闭开机启动

9、关闭内核防火墙
首先编辑vim /etc/selinux/config,如下图所示:

将SELINUX=enforcing改为SELINUX=disabled即可,如下图所示:

10、最后重启系统即可。
本文详细介绍了在CentOS7.5系统中如何使用firewall-cmd替代iptables进行防火墙配置的方法,包括查看、添加、重启及关闭端口等操作步骤,并提供了禁用内核防火墙的具体流程。
1807





