I've used remote and local forwarding with succes in the past, but this time I can't get a setup to work.
What I'm trying to achieve:
Make my sql server publicly reachable so the Google CloudSql can replicate the database.
I have a NAS running debian behind a router that can do port mapping at location A
I am at location B with an CentOS VM running mariadb
From the VM at location B I run the following command
:~$ ssh -f -N -T -R 3306:localhost:3306 my.dyndns.address -p [sshport]
(no mysql server is running on the nas, or at least not at port 3306)
Then on the nas:
:~# ss -anp | grep :330 tcp LISTEN 0 128 127.0.0.1:3306 *:* users:(("sshd",pid=27182,fd=9)) tcp LISTEN 0 128 ::1:3306 :::* users:(("sshd",pid=27182,fd=8))
On the router I have port 33006 forwarded to the nas's port 3306 like so:
I can connect from my own computer to the mysql database, the directive
bind-address was set to '*', I tried also with this directive commented, but as expected, yielded no different results
I'm looking at both machine's output from
journalctl -f, but no information is coming through that can help me to troubleshoot what I'm doing wrong.
— Clarification —
I want to connect from the outside to
my.dyndns.addresstranslates to the public address from my ISP modem.
33006is forwarded on the modem to the local IP of the NAS at port 3306, which is in turn tunneled to the mysql-server (at location B).
I'm testing this with
mysql -h my.dyndns.address --port=33006 -u myuser -p
mysql -h local_ip_on_B -u myuser -p
works just fine
I also tried using a VPN from the db server at location B to location A (the NAS is also the OpenVpn server) and pointing the forwarded port on the ISP's modem directly to IP Address of the IP the db server gets on the tun interface. If I make a second VPN connection to location A, I can connect the database using the IP from the tun interface from my computer.
The error I'm getting is
ERROR 2002 (HY000) Can't connect to MySQL server on ip_of_the_nas.
Can someone help me ?