0

I need to modify my IP tables in order to allow external access to port 3306 (default port used by mysql). I'm using centOS 6.3 and need to access mysql server from a remote machine.

My current IP table:

# Generated by iptables-save v1.4.7 on Tue Nov  6 14:00:04 2012:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [903:231986]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 1194 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1026 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 111 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 32769 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 32803 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5900 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 5900 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 662 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 662 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8002 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 892 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 892 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Tue Nov  6 14:00:04 2012

How should I modify the IP table? Anyone can help me?

I've read a similar question, but my IP tables are very different from that one, so I've decided to open this new question.

Thanks in advance!

PS: I'm very newbie with linux, so any help will be usefull.

1 Answer 1

2

It should be like this:

iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

4
  • You'll need to tell him where in the ruleset to put that. If he puts it at the end, it'll do nothing.
    – MadHatter
    Nov 6, 2012 at 17:49
  • I edited the answer
    – Hex
    Nov 6, 2012 at 17:50
  • Nicely done - that should work.
    – MadHatter
    Nov 6, 2012 at 19:48
  • He'll also need to add the GRANT in MySQL itself when logged into MySQL. E.g. GRANT ALL PRIVILEGES ON database_name.* TO 'db_user'@'ip_address' IDENTIFIED BY 'db_user_password'; Nov 6, 2012 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .