postgresql accept dynamic dns hosts?

2.8k Views Asked by At

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?

2

There are 2 best solutions below

1
On BEST ANSWER

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).

1
On

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.)