centos下Iptables的安装(离线)

centos默认使用的防火墙是firewall,此防火墙不好控制端口防火墙的开闭,所以可以使用三方的插件来进行端口的防火墙开闭。这里就提供了Iptables组件

centos默认使用的防火墙是firewall,此防火墙不好控制端口防火墙的开闭,所以可以使用三方的插件来进行端口的防火墙开闭。这里就提供了Iptables组件来进行控制。本文就将介绍iptables的安装。

提供的安装包:

链接:https://pan.baidu.com/s/1SBRulFqr7ar8sZJrm146Yg 
提取码:vi8z

安装包中包含了两个文件,都是iptables的服务包,解压后,将两个rpm包上传到服务器中。

1、验证服务器上是否装有iptables服务

输入命令:rpm -qa|grep iptables

若存在服务,需要在存在的服务卸载。

输入命令:rpm -e --nodeps iptables-1.4.21-34.el7.x86_64(注意,这里是已经安装过的服务名称,即上面验证是否存在的服务名称)

2、安装服务

输入命令:sudo rpm -Uvh iptables-1.4.21-34.el7.x86_64.rpm

输入命令:sudo rpm -Uvh iptables-services-1.4.21-34.el7.x86_64.rpm

3、验证服务是否安装成功

进入/etc/sysconfig目录下,查看是否存在iptables文件。 

4、关闭firewall

输入命令:sudo systemctl stop firewalld.service

输入命令:sudo systemctl disable firewalld.service

5、启动iptables防火墙

输入命令:systemctl enable iptables

输入命令:systemctl start iptables

查看防火墙状态

输入命令:systemctl status iptables

设置防火墙开机生效

输入命令:systemctl enable iptables.service

重启防火墙 

输入命令:systemctl restart iptables.service