1、题目:CentOS7 禁用firewall防火墙 启用iptables 步骤linux
2、要求:CentOS7 的防火墙默认是firewall 防火墙,如今须要启用iptables防火墙并完成经常使用的配置。tcp
3、步骤:this
1. 关闭firewallspa
1 systemctl stop firewalld.service # 中止firewall 2 systemctl disable firewalld.service # 禁止firewall 开机启动 3 systemctl status firewalld.service # firewall 服务启动状态
2. 安装iptables并配置rest
1 yum install iptables-services # 安装iptables服务
[root@localhost ~]# vi /etc/sysconfig/iptables # 修改iptables配置文件code
# sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configuration *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT # 增长一些端口规范 -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
3. 重启服务并设置为开启启动htm
1 systemctl restart iptables.service # 最后重启使配置生效 2 systemctl enable iptables.service # 设置防火墙开启启动
4、参考文献blog
1 http://www.linuxidc.com/Linux/2015-05/117473.htm # 配置说明2 http://www.linuxidc.com/Linux/2014-03/99159.htm # 使用规范说明