Хорошо, я знаю, что об этом много спрашивали, но я испробовал все советы, которые смог найти, и все еще не могу подключиться к своему серверу Amazon через порт 3306 по telnet.
Добавьте запись iptables для приема подключений на порт 3306:
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Это не помогло, поэтому я отключил брандмауэр с помощью ufw disable
0.0.0.0
в my.cnf
и убедитесь, что порт 3306По-прежнему не повезло. Есть ли другие причины, по которым порт 3306 может быть заблокирован? Почему я не могу подключиться к Telnet? (моя цель - удаленно подключиться к mysql) вот результат 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
Оказывается, ufw disable на самом деле не отключает правила iptables. У меня в iptables была такая строка:
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
и это предотвратило игнорирование добавленных строк ACCEPT. Я добавил iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
строка с -I вместо -A, и это сработало.
окончательный iptables -L
который работал:
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