Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Postgresql server: Allow access to the remote connections within the private network, not external

Presently, I am editing configuration file of the Postgresql for allowing remote connections:

>> sudo nano /etc/postgresql/14/main/pg_hba.conf 

#Allout or Universal connection: 
#To all allow all users, from all remote places access 
#to the all databases, add the following to the above script: 
host        all         all         0.0.0.0/0   scram-sha-256 

How do I limit this access to only to the IPs within our private network. For instance, the range of IP addresses is:

1.1.10.0-255, 
1.1.11.0-255, 
1.1.12.0-255,
1.1.13.0-255

How to configure the file so the remote connection from any of these IPs is allowed?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can copy and modify an example from the documentation

host  all  all  1.1.10.0/23  scram-sha-256
host  all  all  1.1.12.0/23  scram-sha-256

The first entry enables your first two ranges, the second entry enables the other two.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading