centos7中安装以及使用iptables防火墙

iptables服务需要自己安装,命令是:

yum install iptables-services

开启iptables防火墙的命令是:

systemctl start iptables.service
重启iptables防火墙的命令是:

systemctl restart iptables.service
关闭iptables防火墙的命令是:

systemctl stop iptables.service
查看iptables防火墙状态的命令是:

systemctl status iptables.service

使用编辑文件的方式开放特定的端口
很多时候,需要开启防火墙,但是放行某些特定的端口,如何在防火墙开启的状态下,放行50007端口?按照下面的步骤做。

修改规则
主要是编辑/etc/sysconfig/iptables文件,编辑方法很多,可以使用vim编辑,也可以直接把该文件下载到本地,用本地工具编辑。

vi /etc/sysconfig/iptables

2.2.2添加放行的端口
centos7中安装以及使用iptables防火墙
wq保存重启即可