Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IP range in pg_hba.conf for remote access to pgsql

I have a postgresql database on a machine with ip 10.240.81.76. I need to allow remote access to this database from machines 10.240.122.64, 10.240.243.143,...10.240.x.y . I know that i need to make an entry in the pg_hba.conf like the following:

host all all 10.10.29.0/24 trust

What should be the IP range i should be using for the ips in my case ?

Please Help Thank You

like image 798
jimcgh Avatar asked Jul 01 '15 06:07

jimcgh


People also ask

How do I connect to a PostgreSQL database from another machine?

To connect to PostgreSQL from a different machine, you must open port 5432 for remote access. Refer to the FAQ for more information on this. IMPORTANT: By default, the database port for the nodes in this solution cannot be accessed over a public IP address.

How configure Pg_hba conf?

Start PgAdminIII, connect to the PostgreSQL instance as the postgres super user, connect to the database, click Tools, point to Server Configuration, then click pg_hba. conf. Start Notepad or another text editor application and open the pg_hba. conf file from the PostgreSQL installation directory.


1 Answers

The easy answer is

host <database_name> all 10.240.0.0/16 md5

But much depends on your network configuration. Also note the use of md5 for the authentication method; usually only local addresses should use trust.

This assumes that you know the machines on the 10.240.0.0/16 network. That is, obviously, a private range but there can be up to 16K computers in that range. If you are uncertain, make multiple entries in pg_hba.conf for individual addresses or C-class ranges of which you are certain that they need to connect to your server.

like image 97
Patrick Avatar answered Oct 08 '22 15:10

Patrick