CentOS關閉防火牆啟用iptables、開放埠號
CentOS:關閉防火牆,啟用iptables
參考文件:
https://blog.csdn.net/bitterliquor/article/details/70256141
a、關閉firewall:
//停止firewall
systemctl stop firewalld.service
//禁止firewall開機啟動
systemctl disable firewalld.service
b、配置iptables
//安裝
yum install -y iptables-services
#重啟防火牆使配置生效
systemctl restart iptables.service
#設定防火牆開機啟動
systemctl enable iptables.service
#禁止防火牆開機啟動
systemctl disable iptables.service
B、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之前,否則可能導致規則不生效)
參考文件:
https://www.cnblogs.com/grimm/p/5362096.html
C、防火牆命令:
service iptables status --檢視防火牆狀態
servcie iptables stop --臨時關閉防火牆
service iptables start --臨時啟動防火牆
service iptables restart --重啟防火牆
chkconfig iptables off --永久關閉防火牆
chkconfig iptables on --永久開啟防火牆