0

I'm trying to portforward a PostgreSQL port using my DLINK ADSL Router. I have the following IP addresses.

Public Internet IP   197.321.321.32 
PostgreSQL           192.123.123.12:5432    (Port To Forward CentOS 7)

I've configured PostgreSQL to allow remote connections as well as disabled firewalld and selinux for testing purposes.

postgresql.conf

listen_addresses = '*'

pg_hba.conf

# LAN connections
host    dbname    usname    192.123.123.0/24    md5
# Internet connections
host    dbname    usname    197.321.321.0/24    md5

All the computers on the LAN can connect to PostgreSQL fine.

Then I did the port forwarding.

Server Name    External Port    Protocol    Internal Port   Server IP Address   Use Interface   Lan Loopback    Schedule Rule
pbpgsql        5432 to 5432     TCP         5432 to 5432    192.123.123.12      ppp0.1          Disabled        Always

I tried to telnet to test the port

telnet 197.321.321.321.32 5432

Which gives me the response

telnet: connect to address 197.321.321.32: Connection refused

Why is this? I can't connect to the PostgreSQL port from outside the LAN but inside the LAN it works fine

  • maybe there is a problem with copy-paste but ip 197.321.321.32 is incorrect. you cant have an octet > 254 – LilloX Nov 4 '15 at 9:04
  • The IP is just a bogus one to protect the integrity of the server – TheLovelySausage Nov 4 '15 at 9:05
  • @Trent, is there a managed firewall that you are unaware of? – Daniel Nov 4 '18 at 15:38
  • @Daniel after some investigation it seemed that having a database port forwarded on the network was a bad idea. Instead I forwarded the web server instead and interfaced with the database using APIs which seems like the safer way to do things – TheLovelySausage Nov 5 '18 at 6:29
  • @Trent, you should go ahead and post that as your answer then, so that others may benefit. – Daniel Nov 5 '18 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.