Home > Net >  Firewalld how to allow connections on a port to all ips?
Firewalld how to allow connections on a port to all ips?

Time:11-28

I'm trying to configure firewalld on my VPS server and I'm trying to open a port for my postgresql server.

So far, I have done the following:

sudo firewall-cmd --new-zone=postgresqlrule --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --permanent --zone=postgresqlrule --add-port=5432/tcp
sudo firewall-cmd --reload

How do I use --add-source to add a wildcard for all ips?

sudo firewall-cmd --permanent --zone=postgresqlrule --add-source= *

The above returns the following error:

[root@centos-s-1vcpu-512mb-10gb-sfo3-01 ~]# sudo firewall-cmd --permanent --zone=postgresqlrule --add-source= *
usage: see firewall-cmd man page
firewall-cmd: error: unrecognized arguments: mysql80-community-release-el9-1.noarch.rpm steam-game-scraper

I basically have to give some classmates access to this database, but I don't want to have to find out each of their IPs. I couldn't find anything related to opening connections to all IPs online.

CodePudding user response:

Go to pg_hba.conf file in this location (/etc/postgresql/12/main) and add the following line at the end:

host  all  all 0.0.0.0/0 md5

It allows access to all databases for all users.

Restart Postgresql by writing this command service postgresql restart

CodePudding user response:

Resolved! I added my public IP to a different zone so it was already tied to that zone thus refusing connections to anything else.

I removed that source IP, and it's now accepting connections on that port.

  • Related