無法從內部 VM 結構連接到 MariaDB

無法從內部 VM 結構連接到 MariaDB

S1

虛擬機器 1:Ubuntu 應用伺服器

虛擬機器2:MariaDB 1

S2

虛擬機器 3:Ubuntu 應用伺服器

虛擬機器 4:MariaDB 2

從 vm04 和 03 我可以使用連接埠 3306 的連接字串連接到 DB1,但無法從 vm01 和 02 連接 DB2

telnet 可以從 3306 連接到 DB2

DB 的 MariaDB 10.6 和所有 VM 都具有相同的配置。 VM03可以連接到DB2。

當我使用 tcpdump 監聽 DB2 流量時,我可以看到請求正在到達 DB,但之後會發生什麼,我並不確切知道。

任何想法:

netstat -tulpn | 網路統計grep 聽 | grep 3306

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5145/mariadbd
tcp6       0      0 :::3306                 :::*                    LISTEN      5145/mariadbd

編輯:

DB1的錯誤訊息

2023-02-27 12:32:17 5771 [Warning] Aborted connection 5771 to db: 'testdev' user: 'testuser' host: 'vm02' (Got timeout reading communication packets)

路線-n (db2)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         PublicIP        0.0.0.0         UG    0      0        0 eth0
0.0.0.0         192.168.1.151   0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

s1 192.168.2.0/24
s2 192.168.1.0/24

iptables

iptables -A FORWARD -p tcp --source 192.168.2.1/24 --dport 3306 -j ACCEPT
iptables -A FORWARD -p tcp --source 192.168.2.1/24 --dport 3307 -j ACCEPT
iptables -A INPUT -p tcp --source 192.168.2.1/24 --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp --source 192.168.2.1/24 --dport 3307 -j ACCEPT

same for 1.1./24 subnets

相關內容