CentOS 7.0關閉默認防火牆啓用iptables防火牆

CentOS 7.0默認使用的是firewall作爲防火牆,這裏改爲iptables防火牆步驟。

1、關閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啓動
firewall-cmd --state #查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running)

2、

安裝iptables防火牆 
#安裝iptables 
yum install iptables-services

#編輯防火牆文件 
vi /etc/sysconfig/iptables 
添加80和3306端口 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

#重啓防火牆使配置文件生效 
systemctl restart iptables.service

#設置iptables防火牆爲開機啓動項 
systemctl enable iptables.service

關閉SELINUX 
 vi /etc/selinux/config 
 #註釋以下配置 
 SELINUX=enforcing 
 SELINUXTYPE=targeted 
  
 #增加以下配置 
 SELINUX=disabled 
  
 #使配置立即生效 
 setenforce 0




yum remove iptables  #卸載iptables

全文完..........


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章