From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sebastien Flaesch <sebastien.flaesch@4js.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Resolving host to IP address
Date: Mon, 12 Sep 2022 10:11:11 -0400
Message-ID: <1611957.1662991871@sss.pgh.pa.us> (raw)
In-Reply-To: <DBAP191MB1289E076178736EEEB600F28B0449@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
References: <DBAP191MB1289E076178736EEEB600F28B0449@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
Sebastien Flaesch <sebastien.flaesch@4js.com> writes:
> $ psql 'postgresql://toro.strasbourg.4js.com:5437/test1?user=pgsuser&sslmode=verify-ca&sslrootcert=./root.crt&sslcert=./client.crt&sslkey=./client.key'
> psql: error: connection to server at "toro.strasbourg.4js.com" (127.0.1.1), port 5437 failed: FATAL: no pg_hba.conf entry for host "127.0.0.1", user "pgsuser", database "test1", SSL encryption
> What looks strange to me in this error is that first it mentions 127.0.1.1 (ok) but then, 127.0.0.1
Linux doesn't seem to show its routing of the loopback domain in netstat
output, but it's probably much like what macOS shows explicitly:
$ netstat -r -n
Destination Gateway Flags Netif Expire
...
127 127.0.0.1 UCS lo0
127.0.0.1 127.0.0.1 UH lo0
...
That is, the entire 127/8 range is "routed" through 127.0.0.1 and
will look like that to the server. I see similar entries on NetBSD.
Confirming that guess, I see this behavior on RHEL8,
with no particular OpenSSL involvement:
$ psql -h 127.0.1.1
psql (16devel)
Type "help" for help.
postgres=# select client_addr from pg_stat_activity;
client_addr
-------------
...
127.0.0.1
...
Moral: don't try to use addresses in that range as real addresses.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, sebastien.flaesch@4js.com
Subject: Re: Resolving host to IP address
In-Reply-To: <1611957.1662991871@sss.pgh.pa.us>
References: <DBAP191MB1289E076178736EEEB600F28B0449@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> <1611957.1662991871@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox