CentOS 7 關閉防火牆 啓用 iptables 2

CentOS 6.x中防火牆默認是iptables,而CentOS 7.x中防火牆默認是firewall


一、CentOS 6.x

# 查看防火牆狀態
service iptable status

# 臨時關閉防火牆
servcie iptables stop

# 臨時啓動防火牆
service iptables start

# 重啓防火牆
service iptables restart 

# 永久關閉防火牆
chkconfig iptables off

# 永久開啓防火牆
chkconfig iptables on

二、CentOS 7.x

A、關閉firewall

# 停止 firewall
systemctl stop firewalld.service

# 禁止 firewall 開機啓動
systemctl disable firewalld.service

# 查看 firewall 的狀態
systemctl status firewalld.service 

B、安裝iptables

# 安裝
yum install -y iptables-services

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

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

# 禁止防火牆開機啓動
systemctl disable iptables.service

C、配置iptables

vi /etc/sysconfig/iptables

# 添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT 

注意:添加在-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited之前,否則可能導致規則不生效。

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