mysql iptables rule not working

PROBLEM

You added rules for mysql to iptables and it is still not working.  Mysql traffic is still blocked. 


SOLUTIONS

Make sure the order of rules is correct.  Any rule that you add must be inserted before the REJECT rule.  Iptables does not process further rules after REJECT rule.


EXAMPLE

You entered:

iptables -A INPUT -p tcp -s YOUR.SOURCE.IP.HERE  --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

You should have entered

iptables -I INPUT 1 -p tcp -s YOUR.SOURCE.IP.HERE  --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT 1 -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

Notice the number after INPUT, thats the number of an existing rule.  Your rule will be inserted before this rule.

use -I to insert your rule before rule
use -A to append rules to end of iptables rules


OTHER HELPFUL INFO


Command to list iptable rules with line numbers

iptables -vnL --line-numbers


Command to delete iptables rules

iptables -D  (CHAIN NAME HERE: INPUT,OUTPUT or FORWARD) (RULE NUMBER HERE)
example: iptables -D INPUT 6

Command to save iptables after editing on CentOS/REHL

/sbin/service iptables save

Command to restart iptables service and apply changes on CentOS/REHL

service network restart



  • 0 Users Found This Useful
Was this answer helpful?

Powered by WHMCompleteSolution