Mysql

在 FreeBSD 監獄中的 MariaDB 中啟用 IPv6

  • March 26, 2019

我正在嘗試在 FreeBSD 11.2 Jail 上設置 MariaDB 10.2 伺服器。

伺服器正在執行並接受通過 IPv4 的遠端連接。根據sockstat,它也應該在 IPv6 上監聽:

db# sockstat | grep 3306   
mysql    mysqld     17516 177 tcp46 *:3306                *:*

這確實是我想要的,因此我的 my.cnf:

db# cat my.cnf | grep -vE "^#"
[client]
port������������= 3306
socket����������= /tmp/mysql.sock

[mysqld]
port������������= 3306
bind-address����= ::
socket����������= /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K

server-id�������= 1

innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_log_buffer_size = 16M

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

但是,當我嘗試通過 IPv6 連接到它時,我的請求超時:

db# telnet db.local 3306            
Trying fd0b:9867:5eb1::3306...
telnet: connect to address fd0b:9867:5eb1::3306: Operation timed out
telnet: Unable to connect to remote host
db# telnet ::1 3306            
Trying ::1...
telnet: connect to address ::1: Operation timed out
telnet: Unable to connect to remote host

通過 IPv4,它不會:

db# telnet 10.0.0.10 3306
Trying 10.0.0.10...
Connected to db.burnus.net.
Escape character is '^]'.
Y
5.5.5-10.2.22-MariaDB>8vmB=LG)M'zTti5g)3emysql_native_password^CConnection closed by foreign host.                                          
db# telnet 127.0.0.1 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Y
5.5.5-10.2.22-MariaDB?',Jme7}$Wm@70-/FO<~mysql_native_password^CConnection closed by foreign host.

當然,這兩個地址都與監獄的網路介面相關聯:

db# ifconfig em0 | grep inet
��������inet 10.0.0.10 netmask 0xffffffff broadcast 10.0.0.10  
��������inet6 fd0b:9867:5eb1::3306 prefixlen 128

沒有防火牆。

刪除bind-addressmy.cnf 中的文件或將其更改為正確的 IPv6 地址或主機名也無濟於事。你有什麼想法,我可能做錯了什麼?

解決了。自然,它歸結為路由錯誤。上面所說的一切都設置正確,但是主機將埠 3306 上的所有流量重定向到監獄的 IPv4 地址,這不知何故導致 MariaDB 服務不再信任它。

引用自:https://serverfault.com/questions/959300