redhat / centos開啟關閉防火牆


(一)redhat6/centos6
在redhat6/centos6中,Linux默認的防火牆是iptables,啟動與關閉方式如下:

#查看防火牆狀態
service iptables status 

#臨時開啟,重啟機器后失效
service iptables start 
#臨時關閉,重啟機器后失效 
service iptables stop

#開機自啟動
chkconfig iptables on 
#關閉開機自啟動
chkconfig iptables off

 

對於單個端口的管理,例如要允許訪問防火牆上的端口80 ,請附加以下規則:

# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

 

 

(二)redhat7/centos7
在redhat7/centos7中,Linux默認的防火牆是firewalld,啟動與關閉方式如下:

#查看防火牆狀態
firewall-cmd --state 
systemctl status firewalld

#臨時開啟,重啟機器后失效 
systemctl unmask firewalld 
systemctl start firewalld 

#臨時關閉,重啟機器后失效 
systemctl stop firewalld

#開機自啟動 
systemctl enable firewalld

#關閉開機自啟動
systemctl disable firewalld


# 要確保通過訪問firewalld D-Bus接口以及如果需要其他服務也未 # 啟動firewalld firewalld,使用root輸入以下命令:
systemctl mask firewalld

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM