I'm trying to test a postgresql database connectivity using psql command line client. There are several network interfaces on the server and several network interfaces on the client. Each network interface corresponding to a network plane. In pg_hba.conf on server, all connections are denied by default and the clients (actually other servers) who are authorized to connect are granted access using "host" records. Those "host" records only correspond to one network plane.
When I try to connect from client using psql, I had the following error message:
psql: FATAL: no pg_hba.conf entry for host "22.214.171.124", user "FOO", database "BAR", SSL off
As this is a test environment, I added new "host" records with the hostnames / ip addresses corresponding to the other network plane and it worked. The default route on client uses a network interface that is not the postgresql network plane and this is what I want from a system point of view.
That said, to ease testing, is possible to keep my current routes on client and only the right hosts in pg_hba.conf and bind postgresql client on a non-default network interface? I checked psql man, but found nothing.
I found a thread mentioning a "%interface_name" at the end of -h host parameter for ipv6. I tried with my hostname (resolved to an ipv4 address), but it didn't work:
psql: could not translate host name "...%eth0" to address: Name or service not known