2

I am doing work on a server with a postgresql database from home, where I have a dynamic IP, so I use the no-ip ddns service to map my ip to a host name.

I want to edit the pg_hba.conf file so that I can get into the database from home (not setting it to all hosts), but it doesn't seem to work with the host name. Is there anyway to make it work?

mivk
  • 13,452
  • 5
  • 76
  • 69
bash-
  • 6,144
  • 10
  • 43
  • 51
  • 2
    should be posted on http://dba.stackexchange.com/ –  Oct 21 '11 at 14:04
  • It can be done since v. 9, if your server has your dynamic IP in it's `/etc/hosts` file, and is configured to use the hosts file before querying the DNS. I do this, with a cron job to update the hosts file. – mivk Jul 08 '20 at 14:24

2 Answers2

5

This won't work, because the DNS name in pg_hba.conf needs to match the reverse DNS- IP-to-name- lookup result for your IP address: this is assigned by your connectivity provider, and ddns doesn't touch it (just provides an extra forward- name-to-IP- entry).

araqnid
  • 127,052
  • 24
  • 157
  • 134
  • I stuck with configuring DynDNS for my local. May you look at my question http://stackoverflow.com/questions/27304810/domain-name-for-my-pc-configure-router-how-to please? Thanks! – VB_ Dec 05 '14 at 17:07
1

I believe this functionality was introduced in v9.1: http://www.postgresql.org/docs/9.1/interactive/auth-pg-hba-conf.html

If you're using a version prior to that, you could write a cron-fired shell script that does the DNS lookup and dynamically creates the pg_hba.conf file. (You might have to do a HUP after changing it, not sure off the top of my head.)

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98