リモートホストからIPポートを受信するmysqlにTelnetを接続できません

リモートホストからIPポートを受信するmysqlにTelnetを接続できません

次のようにローカルでmysqlプロセスにリモートでログインできます。

bind-address = 0.0.0.0また、次の設定を使用して、MySQLプロセスがすべてのIPを受信して​​いることを確認しました。

root@localhost:~# netstat -plutn | grep mysql
tcp        0      0 0.0.0.0:33060           0.0.0.0:*               LISTEN      39288/mysqld
tcp        0      0 0.0.0.0:7306            0.0.0.0:*               LISTEN      39288/mysqld

そして

root@localhost:~# telnet 82.165.32.59 7306
Trying 82.165.32.59...
Connected to 82.165.32.59.
Escape character is '^]'.
>Host 'linux' is not allowed to connect to this MySQL serverConnection closed by foreign host

ファイアウォールポート7306を開き、次を使用してファイアウォールを再ロードしました。

root@localhost:~# firewall-cmd --zone=public --permanent --add-port=7306/tcp
Warning: ALREADY_ENABLED: 7306:tcp
success
root@localhost:~#  firewall-cmd --reload
success
root@localhost:~# firewall-cmd --list-all
public
  target: default
  icmp-block-inversion: no
  interfaces:
  sources:
  services: dhcpv6-client ssh
  ports: 443/tcp 80/tcp 7306/tcp
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

ただし、リモートホストでTelnetを実行すると、次のように失敗します。

$ telnet 82.165.32.59 7306
Trying 82.165.32.59...

telnet: connect to address 82.165.32.59: Connection timed out

私のオペレーティングシステムは次のとおりです

root@localhost:~# uname -a
Linux localhost 5.4.0-89-generic #100-Ubuntu SMP Fri Sep 24 14:50:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

root@localhost:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

次のようにファイアウォールサービスを再起動してみました。

root@localhost:~# systemctl restart firewalld

また、次のスクリプトを使用してIPTABLESを更新しましたが、役に立ちませんでした。

root@localhost:~# cat fw.stop
#!/bin/sh
echo "Stopping IPv4 firewall and allowing everyone..."
ipt="/sbin/iptables"
## Failsafe - die if /sbin/iptables not found
[ ! -x "$ipt" ] && { echo "$0: \"${ipt}\" command not found."; exit 1; }
$ipt -P INPUT ACCEPT
$ipt -P FORWARD ACCEPT
$ipt -P OUTPUT ACCEPT
$ipt -F
$ipt -X
$ipt -t nat -F
$ipt -t nat -X
$ipt -t mangle -F
$ipt -t mangle -X
$ipt -t raw -F
$ipt -t raw -X

以下のウェブサイトを利用してポート7306が外部に開いていることも確認しましたが、こんな感じです。Port 7306 is closed on 82.165.32.59.

https://www.yougetsignal.com/tools/open-ports/

以下は出力ですがiptables -L、その結果が何なのか理解できる専門知識がありません。

root@localhost:~# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED,DNAT
ACCEPT     all  --  anywhere             anywhere
INPUT_direct  all  --  anywhere             anywhere
INPUT_ZONES  all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere             ctstate INVALID
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED,DNAT
ACCEPT     all  --  anywhere             anywhere
FORWARD_direct  all  --  anywhere             anywhere
FORWARD_IN_ZONES  all  --  anywhere             anywhere
FORWARD_OUT_ZONES  all  --  anywhere             anywhere
DROP       all  --  anywhere             anywhere             ctstate INVALID
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere
OUTPUT_direct  all  --  anywhere             anywhere

Chain FORWARD_IN_ZONES (1 references)
target     prot opt source               destination
FWDI_public  all  --  anywhere             anywhere            [goto]

Chain FORWARD_OUT_ZONES (1 references)
target     prot opt source               destination
FWDO_public  all  --  anywhere             anywhere            [goto]

Chain FORWARD_direct (1 references)
target     prot opt source               destination

Chain FWDI_public (1 references)
target     prot opt source               destination
FWDI_public_pre  all  --  anywhere             anywhere
FWDI_public_log  all  --  anywhere             anywhere
FWDI_public_deny  all  --  anywhere             anywhere
FWDI_public_allow  all  --  anywhere             anywhere
FWDI_public_post  all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere

Chain FWDI_public_allow (1 references)
target     prot opt source               destination

Chain FWDI_public_deny (1 references)
target     prot opt source               destination

Chain FWDI_public_log (1 references)
target     prot opt source               destination

Chain FWDI_public_post (1 references)
target     prot opt source               destination

Chain FWDI_public_pre (1 references)
target     prot opt source               destination

Chain FWDO_public (1 references)
target     prot opt source               destination
FWDO_public_pre  all  --  anywhere             anywhere
FWDO_public_log  all  --  anywhere             anywhere
FWDO_public_deny  all  --  anywhere             anywhere
FWDO_public_allow  all  --  anywhere             anywhere
FWDO_public_post  all  --  anywhere             anywhere

Chain FWDO_public_allow (1 references)
target     prot opt source               destination

Chain FWDO_public_deny (1 references)
target     prot opt source               destination

Chain FWDO_public_log (1 references)
target     prot opt source               destination

Chain FWDO_public_post (1 references)
target     prot opt source               destination

Chain FWDO_public_pre (1 references)
target     prot opt source               destination

Chain INPUT_ZONES (1 references)
target     prot opt source               destination
IN_public  all  --  anywhere             anywhere            [goto]

Chain INPUT_direct (1 references)
target     prot opt source               destination

Chain IN_public (1 references)
target     prot opt source               destination
IN_public_pre  all  --  anywhere             anywhere
IN_public_log  all  --  anywhere             anywhere
IN_public_deny  all  --  anywhere             anywhere
IN_public_allow  all  --  anywhere             anywhere
IN_public_post  all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere

Chain IN_public_allow (1 references)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:ssh ctstate NEW,UNTRACKED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:https ctstate NEW,UNTRACKED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http ctstate NEW,UNTRACKED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:mysql ctstate NEW,UNTRACKED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:7306 ctstate NEW,UNTRACKED

Chain IN_public_deny (1 references)
target     prot opt source               destination

Chain IN_public_log (1 references)
target     prot opt source               destination

Chain IN_public_post (1 references)
target     prot opt source               destination

Chain IN_public_pre (1 references)
target     prot opt source               destination

Chain OUTPUT_direct (1 references)
target     prot opt source               destination

何か提案してもらえますか?

ベストアンサー1

サーバーは次のように構成されます。https://cloudpanel.ionos.de/

ポータルにログインすると、Webダッシュボードにポート7306(受信トラフィック)へのアクセスを許可するファイアウォールオプションがあります。

誰かが答えを明らかにすることができれば、リモートホストがポートにアクセスするのをブロックするものが何であるかを理解できません。

ポートを選択してサーバーを再起動すると、ポートが接続されます。

助けてくれてありがとう。

おすすめ記事