In this case there are two server:
- 1st Server
This server has two network interface. First is set using public IP for example 202.77.10.100
The second interface is connected to 2nd server in private network using IP 192.168.1.100 - 2nd Server
Connected to 1st server in private network using IP 192.168.1.200
The 2nd server is installed Postgre server as a database server using port 5432
And make sure the postgre database server is allowing connection from remote for ip 192.168.1.100 (this can be set on pg_hba.conf)
Because the 2nd server is not visible in public, not using public IP, your laptop can't just access to 192.168.1.200. (In this case your laptop is in different network)
The laptop can access the database through the 1st Server (public IP)
Let's say my laptop access to 202.77.10.100 on port 5500, which will be set to be redirected to 192.168.1.200 on port 5432. We can configure this using TCP Redirection server.
Make sure you have installed rinetd on your linux machine (1st server)
Most the executable case is placed on /usr/sbin/rinetd
And the configuration is on /etc/rinetd.conf
Open the /etc/rinetd.conf, add following lines
202.77.10.100 5500 192.168.1.200 5432
Which means if there is incoming request 202.77.10.100 5500 on port 5500, please redirect it to 192.168.1.200 in port 5432
Run the rinetd
/usr/sbin/rinetd -c /etc/rinetd.conf
Run
netstat -atn | grep 202.77.10.100:5500
You should see there is listening port there. for 202.77.10.100:5500
Now you can access the database from PgAdmin by using 202.77.10.100 as host, and using port 5500.
No comments:
Post a Comment