在/etc/sysconfig下找到iptables檔案,打開後進行編輯,添加一行:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
重新啟動防火牆
/etc/rc.d/init.d/iptables restart
使用iptables -L -n 檢視現在的防火牆設定,果然發現成功了。
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:443
ACCEPT tcp — 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:3306