I have several databases hosted outside the application server, ex: DB instances:
192.168.178.21:5432
192.168.178.22:5432
192.168.178.23:5432
app-server: 192.168.178.11
now I want to forward the external dbs to ports 5431-5433 and be able to connect with psql to localhost:
psql -h 127.0.0.1 -p 5432 -U <user> -d <db>
I get:
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
services on this server are only allowed to connect to localhost, additionally these ports will be forwarded with ssh.
I tried firewalld masquerade:
firewall-cmd --zone=internal --add-masquerade --permanent
firewall-cmd --zone=internal --add-forward-port=port=5432:proto=tcp:toport=5432:toaddr=192.168.178.22 --permanent
firewall-cmd --reload
Any ideas? (I've cowered several manuals, including CentOS, Fedora and Redhat intros)
EDIT: Only Postgres Ports are open on the respective servers, nothing else. I will try using a postgresql aware gateway like crunchy-proxy