Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cE2Ma-00060s-2c for pgsql-admin@arkaria.postgresql.org; Mon, 05 Dec 2016 23:08:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cE2MZ-0007OQ-69 for pgsql-admin@arkaria.postgresql.org; Mon, 05 Dec 2016 23:07:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cE2Kr-0005SM-P8 for pgsql-admin@postgresql.org; Mon, 05 Dec 2016 23:06:13 +0000 Received: from mailfront2.g2host.com ([209.98.94.162] helo=g2host.com) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cE2Kh-000806-Vc for pgsql-admin@postgresql.org; Mon, 05 Dec 2016 23:06:11 +0000 Received: from [173.160.127.121] (account dennisr@visi.com HELO cletus.kabonkulator.com) by visi.com (CommuniGate Pro SMTP 6.1.11) with ESMTPSA id 71530328; Mon, 05 Dec 2016 17:06:00 -0600 From: "dennisr@visi.com" Message-Id: <369ED3B4-CAF3-4BBB-904F-E86999249D8E@visi.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_53D79964-7273-4A4D-99BC-18FCD104C17B" Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: Are dns CNAME's allowed or useable in pg_hba.conf hostname specification Date: Mon, 5 Dec 2016 17:05:59 -0600 In-Reply-To: Cc: Scott Whitney To: pgsql-admin@postgresql.org References: <576363D5-19B5-4B34-A3C1-4D8BF63D3C78@visi.com> <712E05C9-E2D7-49CD-834E-26BA911C8D8A@visi.com> X-Mailer: Apple Mail (2.3251) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org --Apple-Mail=_53D79964-7273-4A4D-99BC-18FCD104C17B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Thanks for the quick reply. Here=E2=80=99s some details on how we have = things configured. We are using RHEL 7.3, the DNS names below have been changed to protect = the innocent or not so innocent depending on your point of view. If I do a nslookup on the database host against the following CNAME = some-cname-host.example.com I get: $> nslookup some-cname-host.example.com = Server: 10.97.40.215 Address: 10.97.40.215#53 some-cname-host.example.com canonical name =3D = canonical-host-name.example.com. Name: canonical-host-name.example.com Address: 10.65.160.213 =20 When I do the reverse lookup on the IP address return above I get the = following: $> nslookup 10.65.160.213 Server: 10.97.40.215 Address: 10.97.40.215#53 213.160.65.10.in-addr.arpa name =3D = canonical-host-name.example.com. In our pg_hba.conf I have a line: # TYPE DATABASE USER ADDRESS METHOD hostssl replication streaming_user_name = some-cname-host.example.com But when I try to connect as the streaming_user_name with the following = command, I get the following error (postgresql_hostname is the host = where I ran the nslookups above): bash-4.2$ psql -U streaming_user_name -h postgresql_hostname = -c "IDENTIFY_SYSTEM" replication=3D1 =09 psql: FATAL: no pg_hba.conf entry for replication connection = from host "10.65.160.213", user "streaming_user_name", SSL on FATAL: no pg_hba.conf entry for replication connection from = host "10.65.160.213", user "streaming_user_name", SSL off So I am not sure what I would need to fix or add on the database host to = allow it to resolve the CNAME in way the postgres instance could use it = and have it pass the validation rules from the documentation. Am I = missing something in the DNS configurations? > On Dec 5, 2016, at 3:56 PM, Scott Whitney wrote: >=20 > Honestly, if your DNS is properly setup, it should work fine, yes. >=20 >=20 > From: pgsql-admin-owner@postgresql.org = on behalf of dennisr@visi.com = > Sent: Monday, December 5, 2016 3:49 PM > To: pgsql-admin@postgresql.org > Subject: [ADMIN] Are dns CNAME's allowed or useable in pg_hba.conf = hostname specification > =20 > =46rom reading the doc=E2=80=99s it looks like a CNAME will not in = general work as a hostname specification in pg_hba.conf. Is that a = correct interpretation of the the documentation? >=20 > =46rom the doc=E2=80=99s ( = https://www.postgresq= l.org/docs/current/static/auth-pg-hba-conf.html >=20 > If a host name is specified (anything that is not an IP address range = or a special key word is treated as a host name), that name is compared = with the result of a reverse name resolution of the client's IP address = (e.g., reverse DNS lookup, if DNS is used). Host name comparisons are = case insensitive. If there is a match, then a forward name resolution = (e.g., forward DNS lookup) is performed on the host name to check = whether any of the addresses it resolves to are equal to the client's IP = address. If both directions match, then the entry is considered to = match. (The host name that is used in pg_hba.conf should be the one that = address-to-name resolution of the client's IP address returns, otherwise = the line won't be matched. Some host name databases allow associating an = IP address with multiple host names, but the operating system will only = return one host name when asked to resolve an IP address.) >=20 >=20 >=20 > --=20 > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org = ) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin = >=20 >=20 > Journyx, Inc. > 7600 Burnet Road #300=20 > Austin, TX 78757=20 > www.journyx.com =20 >=20 > p 512.834.8888=20 > f 512-834-8858=20 >=20 > Do you receive our promotional emails? You can subscribe or = unsubscribe to those emails at = http://go.journyx.com/emailPreference/e/4932/714/ = =20 --Apple-Mail=_53D79964-7273-4A4D-99BC-18FCD104C17B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Thanks for the quick = reply.  Here=E2=80=99s some details on how we have things = configured.

We are using RHEL 7.3,  the DNS names below = have been changed to protect the innocent or not so innocent depending = on your point of view.

If I do a nslookup on the = database host against the following CNAME some-cname-host.example.com I get:

$> nslookup  some-cname-host.example.com
= Server:          =    10.97.40.215
= Address:          = 10.97.40.215#53

some-cname-host.example.com         = canonical name =3D canonical-host-name.example.com.
= Name: canonical-host-name.example.com
Address: = 10.65.160.213
 
When = I do the reverse lookup on the IP address return above I get the = following:

$> nslookup = 10.65.160.213
= Server:          =    10.97.40.215
= Address:          = 10.97.40.215#53

= 213.160.65.10.in-addr.arpa    name =3D canonical-host-name.example.com.


In our pg_hba.conf I have a line:

# TYPE = DATABASE  USER ADDRESS = METHOD
hostssl replication = streaming_user_name  = some-cname-host.example.com

But when I try to connect as the streaming_user_name with the = following command, I get the following error (postgresql_hostname is the = host where I ran the nslookups above):

= bash-4.2$ psql -U streaming_user_name -h = postgresql_hostname   -c = "IDENTIFY_SYSTEM"   replication=3D1
=
psql: FATAL:  no pg_hba.conf = entry for replication connection from host "10.65.160.213", user = "streaming_user_name", SSL on
FATAL:  no pg_hba.conf entry = for replication connection from host "10.65.160.213", user = "streaming_user_name", SSL off

So I am not sure what I would = need to fix or add on the database host to allow it to resolve the CNAME = in way the postgres instance could use it and have it pass the = validation rules from the documentation.  Am I missing something in = the DNS configurations?


On Dec 5, 2016, at 3:56 PM, Scott Whitney = <scott@journyx.com> wrote:

Honestly, if your DNS is properly setup, = it should work fine, yes.



From: pgsql-admin-owner@postgresql.org <pgsql-admin-owner@postgresql.org> on behalf of dennisr@visi.com <dennisr@visi.com>
Sent: Monday, December 5, 2016 = 3:49 PM
To: pgsql-admin@postgresql.org
Subject: [ADMIN] Are dns CNAME's = allowed or useable in pg_hba.conf hostname specification
 
=46rom = reading the doc=E2=80=99s it looks like a CNAME will not in general work = as a hostname specification in pg_hba.conf.  Is that a correct = interpretation of the the documentation?

=46r= om the doc=E2=80=99s (https://www.postgresql.org/docs/current/static/auth-pg-hba-conf= .html

If a host name is specified = (anything that is not an IP address range or a special key word is = treated as a host name), that name is compared with the result of a = reverse name resolution of the client's IP address (e.g., reverse DNS = lookup, if DNS is used). Host name comparisons are case insensitive. If = there is a match, then a forward name resolution (e.g., forward DNS = lookup) is performed on the host name to check whether any of the = addresses it resolves to are equal to the client's IP address. If both = directions match, then the entry is considered to match. (The host name = that is used in pg_hba.conf should be the one that address-to-name = resolution of the client's IP address returns, otherwise the line won't = be matched. Some host name databases allow associating an IP address = with multiple host names, but the operating system will only return one = host name when asked to resolve an IP address.)



-- 
Sent via = pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes = to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin


Journyx, Inc.
7600 = Burnet Road #300 
Austin, TX 78757 
www.journyx.com 

p = 512.834.8888 
f = 512-834-8858 

Do you receive our promotional emails? You can subscribe or = unsubscribe to those emails at http://go.journyx.com/emailPreference/e/4932/714/ 

= --Apple-Mail=_53D79964-7273-4A4D-99BC-18FCD104C17B--