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 # 使用規範說明