I have 2 servers, DB_server (1.1.1.1) and app_server (2.2.2.2)
created a user on DB_server for app_server (with 2.2.2.2 as hostname) But I am not able to connect from app_server to db_server.
When I shut down iptables on db_server, I am able to connect fine. So that makes me think the issue is with iptables on db_server.
bind-address is 0.0.0.0 on db_server, which is working.
This is what I have done so far, from app_server, with iptables enabled on db_server:
# telnet 1.1.1.1 3306
Trying 1.1.1.1...
telnet: connect to address 1.1.1.1: No route to host
With iptables disabled on db_server:
# telnet 1.1.1.1 3306
Trying 1.1.1.1...
Connected to 1.1.1.1.
Escape character is '^]'.
R
So that means I am able to connect fine without iptables.
This is iptables -S on db_server
# iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-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 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 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8001 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10081 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 10090:10100 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -s 2.2.2.2/32 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
I have been trying to make this work for a while now, came up with this to allow the connection from 2.2.2.2, but it is not working after iptables-save
-A INPUT -s 2.2.2.2/32 -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
I am kind of lost, I feel like I am doing the correct things, but it is not working... Any pointers?