I am trying to add the following line in the /etc/sysconfig/iptables in CentOS so I will be allowed to access mysql.

-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

I already did # service iptables restart and that doesn't resolve this. I have already done this a couple of times for other ports and a simple service restart does not help. Is there a way to go around this without rebooting the server?


Agreed that topic should be migrated.

However, one thing to verify is that your ACCEPT rules come before your REJECT rule(s).

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

first and foremost, it's not a good practice to edit the /etc/sysconfig/iptables file. To add rules on your iptables, do something like this:

/sbin/iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
/sbin/service iptables save
/sbin/service iptables restart

well, anyway..with regards to your question, if you still don't have some important rules on your iptables, try to flush/remove all rules

/sbin/iptables -F

then, add your desired rules. don't forget to add the basic rules like to accept ports 80 (http), 22 (ssh), 21 (ftp), 443 (https), etc.

but if you already have some configured rules, just remove your manual input rule and add/insert it the right way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.