1

Ok, I know this has been asked a lot, but I've tried every advice I can find and I still can't telnet to my Amazon server on port 3306.

  1. Add iptables entry for accepting connections on port 3306:

    iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

  2. That doesn't fix it, so I turned off the firewall with ufw disable

  3. Add 3306 from anywhere in security group section on Amazon AWS for my specific server. (relevant line: MYSQL TCP 3306 0.0.0.0/0)
  4. Change bind-address to 0.0.0.0 in my.cnf and make sure port is 3306

Still no luck. Is there any other reasons why port 3306 might be blocked? Why can't I connect with telnet? (ofc my aim is to connect with mysql remotely) here is the result of netstat -lnptu

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      16883/mysqld
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      932/sshd
tcp6       0      0 :::80                   :::*                    LISTEN      14030/apache2
tcp6       0      0 :::22                   :::*                    LISTEN      932/sshd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           512/dhclient
udp        0      0 0.0.0.0:29313           0.0.0.0:*                           512/dhclient
udp6       0      0 :::28486                :::*                                512/dhclient

1 Answer 1

1

It turns out ufw disable doesn't actually turn iptables rules off. I had this line in my iptables:

REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

and this prevented the appended ACCEPT lines to be ignored. I added the iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT line with -I instead of -A and it worked.

final iptables -L which worked:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

You must log in to answer this question.

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