Re: Find all running postgres DB servers on a network - Mailing list pgsql-admin

From ojas dubey
Subject Re: Find all running postgres DB servers on a network
Date
Msg-id AANLkTikrdfvNy2ef-5A51EKBKRQu8OFf7yYG6wxQdDZV@mail.gmail.com
Whole thread Raw
In response to Re: Find all running postgres DB servers on a network  (Frederiko Costa <frederiko@gmail.com>)
List pgsql-admin
Hi everyone,
 
I have to bring this up again. I ran the nmap command nmap --open -sV -p5432 -oG dbserverlist.txt 172.28.26.0/24 to scan the network for running instances of Postgres servers on my network. The serverlist had the following output: (I am excluding the IP addresses with Status:Down to simplify the output)
 
# Nmap 5.21 scan initiated Thu Dec 30 12:02:52 2010 as: nmap.exe --open -sV -p5432 -oG dbserverlist.txt 172.28.26.0/24
Host: 172.28.26.0 ()       Status: Down
Host: 172.28.26.4 ()       Status: Down
Host: 172.28.26.5 ()       Status: Down
Host: 172.28.26.38 ()      Status: Down
Host: 172.28.26.39 ()      Status: Down
Host: 172.28.26.1 ()       Status: Up
Host: 172.28.26.1 ()       Status: Up
Host: 172.28.26.2 ()       Status: Up
Host: 172.28.26.2 ()       Status: Up
Host: 172.28.26.3 ()       Status: Up
Host: 172.28.26.3 ()       Status: Up
Host: 172.28.26.7 ()       Status: Up
Host: 172.28.26.7 ()       Status: Up
Host: 172.28.26.14 ()      Status: Up
Host: 172.28.26.14 ()      Status: Up
Host: 172.28.26.18 ()      Status: Up
Host: 172.28.26.18 ()      Status: Up
Host: 172.28.26.19 ()      Status: Up
Host: 172.28.26.19 ()      Ports: 5432/open/tcp//tcpwrapped///
Host: 172.28.26.30 ()      Status: Up
Host: 172.28.26.30 ()      Status: Up
Host: 172.28.26.36 ()      Status: Up
Host: 172.28.26.36 ()      Status: Up
Host: 172.28.26.40 ()      Status: Up
Host: 172.28.26.40 ()      Ports: 5432/unknown/tcp//postgresql///
Host: 172.28.26.44 ()      Status: Down
Host: 172.28.26.48 ()      Status: Down
Host: 172.28.26.50 ()      Status: Down
Host: 172.28.26.51 ()      Status: Down
Host: 172.28.26.253 ()    Status: Down
Host: 172.28.26.254 ()    Status: Down
Host: 172.28.26.255 ()    Status: Down
Host: 172.28.26.41 ()      Status: Up
Host: 172.28.26.41 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.42 ()      Status: Up
Host: 172.28.26.42 ()      Status: Up
Host: 172.28.26.43 ()      Status: Up
Host: 172.28.26.43 ()      Status: Up
Host: 172.28.26.45 ()      Status: Up
Host: 172.28.26.45 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.46 ()      Status: Up
Host: 172.28.26.46 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.47 ()      Status: Up
Host: 172.28.26.47 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.49 ()      Status: Up
Host: 172.28.26.49 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.56 ()      Status: Up
Host: 172.28.26.56 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.57 ()      Status: Up
Host: 172.28.26.57 ()      Status: Up
Host: 172.28.26.61 ()      Status: Up
Host: 172.28.26.61 ()      Ports: 5432/open/tcp//tcpwrapped///
Host: 172.28.26.68 ()      Status: Up
Host: 172.28.26.68 ()      Status: Up
Host: 172.28.26.74 ()      Status: Up
Host: 172.28.26.74 ()      Status: Up
Host: 172.28.26.76 ()      Status: Up
Host: 172.28.26.76 ()      Status: Up
Host: 172.28.26.77 ()      Status: Up
Host: 172.28.26.77 ()      Status: Up
Host: 172.28.26.78 ()      Status: Up
Host: 172.28.26.78 ()      Status: Up
Host: 172.28.26.79 ()      Status: Up
Host: 172.28.26.79 ()      Status: Up
Host: 172.28.26.81 ()      Status: Up
Host: 172.28.26.81 ()      Status: Up
Host: 172.28.26.85 ()      Status: Up
Host: 172.28.26.85 ()      Status: Up
Host: 172.28.26.86 ()      Status: Up
Host: 172.28.26.86 ()      Status: Up
Host: 172.28.26.87 ()      Status: Up
Host: 172.28.26.87 ()      Ports: 5432/open/tcp/////
Host: 172.28.26.88 ()      Status: Up
Host: 172.28.26.88 ()      Status: Up
Host: 172.28.26.89 ()      Status: Up
Host: 172.28.26.89 ()      Status: Up
Host: 172.28.26.90 ()      Status: Up
Host: 172.28.26.90 ()      Status: Up
Host: 172.28.26.91 ()      Status: Up
Host: 172.28.26.91 ()      Status: Up
Host: 172.28.26.92 ()      Status: Up
Host: 172.28.26.92 ()      Status: Up
Host: 172.28.26.93 ()      Status: Up
Host: 172.28.26.93 ()      Status: Up
Host: 172.28.26.94 ()      Status: Up
Host: 172.28.26.94 ()      Status: Up
Host: 172.28.26.96 ()      Status: Up
Host: 172.28.26.96 ()      Status: Up
Host: 172.28.26.99 ()      Status: Up
Host: 172.28.26.99 ()      Status: Up
Host: 172.28.26.101 ()    Status: Up
Host: 172.28.26.101 ()    Status: Up
Host: 172.28.26.103 ()    Status: Up
Host: 172.28.26.103 ()    Status: Up
Host: 172.28.26.104 ()    Status: Up
Host: 172.28.26.104 ()    Status: Up
Host: 172.28.26.107 ()    Status: Up
Host: 172.28.26.107 ()    Status: Up
Host: 172.28.26.108 ()    Status: Up
Host: 172.28.26.108 ()    Status: Up
Host: 172.28.26.109 ()    Status: Up
Host: 172.28.26.109 ()    Status: Up
Host: 172.28.26.110 ()    Status: Up
Host: 172.28.26.110 ()    Status: Up
Host: 172.28.26.111 ()    Status: Up
Host: 172.28.26.111 ()    Status: Up
Host: 172.28.26.112 ()    Status: Up
Host: 172.28.26.112 ()    Status: Up
Host: 172.28.26.113 ()    Status: Up
Host: 172.28.26.113 ()    Status: Up
Host: 172.28.26.114 ()    Status: Up
Host: 172.28.26.114 ()    Status: Up
Host: 172.28.26.115 ()    Status: Up
Host: 172.28.26.115 ()    Ports: 5432/open/tcp/////
Host: 172.28.26.116 ()    Status: Up
Host: 172.28.26.116 ()    Status: Up
Host: 172.28.26.117 ()    Status: Up
Host: 172.28.26.117 ()    Status: Up
Host: 172.28.26.118 ()    Status: Up
Host: 172.28.26.118 ()    Status: Up
Host: 172.28.26.119 ()    Status: Up
Host: 172.28.26.119 ()    Status: Up
Host: 172.28.26.121 ()    Status: Up
Host: 172.28.26.121 ()    Status: Up
Host: 172.28.26.122 ()    Status: Up
Host: 172.28.26.122 ()    Status: Up
Host: 172.28.26.123 ()    Status: Up
Host: 172.28.26.123 ()    Status: Up
Host: 172.28.26.124 ()    Status: Up
Host: 172.28.26.124 ()    Status: Up
Host: 172.28.26.125 ()    Status: Up
Host: 172.28.26.125 ()    Status: Up
Host: 172.28.26.126 ()    Status: Up
Host: 172.28.26.126 ()    Status: Up
Host: 172.28.26.127 ()    Status: Up
Host: 172.28.26.127 ()    Status: Up
Host: 172.28.26.130 ()    Status: Up
Host: 172.28.26.130 ()    Status: Up
Host: 172.28.26.132 ()    Status: Up
Host: 172.28.26.132 ()    Status: Up
Host: 172.28.26.135 ()    Status: Up
Host: 172.28.26.135 ()    Status: Up
Host: 172.28.26.136 ()    Status: Up
Host: 172.28.26.136 ()    Status: Up
Host: 172.28.26.137 ()    Status: Up
Host: 172.28.26.137 ()    Status: Up
Host: 172.28.26.138 ()    Status: Up
Host: 172.28.26.138 ()    Status: Up
Host: 172.28.26.139 ()    Status: Up
Host: 172.28.26.139 ()    Status: Up
Host: 172.28.26.140 ()    Status: Up
Host: 172.28.26.140 ()    Status: Up
Host: 172.28.26.144 ()    Status: Up
Host: 172.28.26.144 ()    Status: Up
Host: 172.28.26.145 ()    Status: Up
Host: 172.28.26.145 ()    Status: Up
Host: 172.28.26.146 ()    Status: Up
Host: 172.28.26.146 ()    Status: Up
Host: 172.28.26.148 ()    Status: Up
Host: 172.28.26.148 ()    Status: Up
Host: 172.28.26.149 ()    Status: Up
Host: 172.28.26.149 ()    Status: Up
Host: 172.28.26.152 ()    Status: Up
Host: 172.28.26.152 ()    Status: Up
Host: 172.28.26.154 ()    Status: Up
Host: 172.28.26.154 ()    Status: Up
Host: 172.28.26.157 ()    Status: Up
Host: 172.28.26.157 ()    Status: Up
Host: 172.28.26.158 ()    Status: Up
Host: 172.28.26.158 ()    Status: Up
Host: 172.28.26.159 ()    Status: Up
Host: 172.28.26.159 ()    Status: Up
Host: 172.28.26.160 ()    Status: Up
Host: 172.28.26.160 ()    Status: Up
Host: 172.28.26.161 ()    Status: Up
Host: 172.28.26.161 ()    Status: Up
Host: 172.28.26.162 ()    Status: Up
Host: 172.28.26.162 ()    Status: Up
Host: 172.28.26.163 ()    Status: Up
Host: 172.28.26.163 ()    Status: Up
Host: 172.28.26.165 ()    Status: Up
Host: 172.28.26.165 ()    Status: Up
Host: 172.28.26.169 ()    Status: Up
Host: 172.28.26.169 ()    Status: Up
Host: 172.28.26.170 ()    Status: Up
Host: 172.28.26.170 ()    Status: Up
Host: 172.28.26.172 ()    Status: Up
Host: 172.28.26.172 ()    Status: Up
Host: 172.28.26.178 ()    Status: Up
Host: 172.28.26.178 ()    Status: Up
Host: 172.28.26.181 ()    Status: Up
Host: 172.28.26.181 ()    Status: Up
Host: 172.28.26.184 ()    Status: Up
Host: 172.28.26.184 ()    Status: Up
Host: 172.28.26.187 ()    Status: Up
Host: 172.28.26.187 ()    Ports: 5432/open/tcp/////
Host: 172.28.26.197 ()    Status: Up
Host: 172.28.26.197 ()    Status: Up
Host: 172.28.26.202 ()    Status: Up
Host: 172.28.26.202 ()    Status: Up
Host: 172.28.26.205 ()    Status: Up
Host: 172.28.26.205 ()    Status: Up
Host: 172.28.26.206 ()    Status: Up
Host: 172.28.26.206 ()    Status: Up
Host: 172.28.26.208 ()    Status: Up
Host: 172.28.26.208 ()    Status: Up
# Nmap done at Thu Dec 30 12:03:02 2010 -- 256 IP addresses (97 hosts up) scanned in 10.29 seconds
 
From the above output I concluded that the IP addresses with port status of the format Ports: 5432/open/tcp///// are the running instances of the dbservers which gave the correct result for my networl. But running the same command on another network gave me the following output:
 
# Nmap 5.21 scan initiated Tue Jan 04 21:27:09 2011 as: C:\Documents and Settings\Administrator\Application Data\nmap\nmap.exe --open -sV -p5432 -oG dbserverlist.txt 192.168.1.0/24
Host: 192.168.1.0 () Status: Down
Host: 192.168.1.2 () Status: Down
Host: 192.168.1.108 () Status: Down
Host: 192.168.1.109 () Status: Down
Host: 192.168.1.1 () Status: Up
Host: 192.168.1.1 () Status: Up
Host: 192.168.1.11 () Status: Up
Host: 192.168.1.11 () Status: Up
Host: 192.168.1.45 () Status: Up
Host: 192.168.1.45 () Status: Up
Host: 192.168.1.46 () Status: Up
Host: 192.168.1.46 () Status: Up
Host: 192.168.1.56 () Status: Up
Host: 192.168.1.56 () Status: Up
Host: 192.168.1.59 () Status: Up
Host: 192.168.1.59 () Status: Up
Host: 192.168.1.99 () Status: Up
Host: 192.168.1.99 () Status: Up
Host: 192.168.1.100 () Status: Up
Host: 192.168.1.100 () Status: Up
Host: 192.168.1.101 () Status: Up
Host: 192.168.1.101 () Status: Up
Host: 192.168.1.102 () Status: Up
Host: 192.168.1.102 () Status: Up
Host: 192.168.1.106 () Status: Up
Host: 192.168.1.106 () Status: Up
Host: 192.168.1.107 () Status: Up
Host: 192.168.1.107 () Status: Up
Host: 192.168.1.111 () Status: Down
Host: 192.168.1.110 () Status: Up
Host: 192.168.1.110 () Ports: 5432/unknown/tcp//postgresql///
Host: 192.168.1.113 () Status: Down
Host: 192.168.1.114 () Status: Down
Host: 192.168.1.251 () Status: Down
Host: 192.168.1.252 () Status: Down
Host: 192.168.1.253 () Status: Down
Host: 192.168.1.254 () Status: Down
Host: 192.168.1.255 () Status: Down
Host: 192.168.1.112 () Status: Up
Host: 192.168.1.112 () Status: Up
# Nmap done at Tue Jan 04 21:27:13 2011 -- 256 IP addresses (14 hosts up) scanned in 4.44 seconds
Now I am unable to understand the difference between the port status Ports: 5432/open/tcp///// and Ports: 5432/unknown/tcp//postgresql/// as in what does the port status unknown imply ?
 
Also please help me out if I am using the wrong command for detection of the postgres service. Thanks all in advance.
 
Regards,
Ojas

On Thu, Nov 18, 2010 at 10:40 PM, Frederiko Costa <frederiko@gmail.com> wrote:
I believe in this case you will have to talk with the sysadmin and have an agreement about this requirement for your application. I don't know about Spiceworks, but I see nmap as an application working on layer 3/4, so you may be subject to firewall rules or anything defined in the security policy.

~Fred


On Thu, Nov 18, 2010 at 7:26 AM, ojas dubey <ojas.dubey@gmail.com> wrote:
Thank you Rich,Fred,Scott,Viktor and Gerard for your replies.

Actually I am neither the system administrator nor the person who set up all the servers. I am developing an application which would provide the user with a list of running Postgres DB servers from which the user can select one. So I was wondering if scanning ports  using nmap or Spiceworks would get me into trouble with the System administrator for trying to flood the network with my requests or not ?

Regards,
Ojas


On Thu, Nov 18, 2010 at 2:51 AM, Rich <rhdyes@gmail.com> wrote:
Use nmap. Unless you deliberately changed the IP port you should have no problem.  Are you the one who setup all the servers?


On Wed, Nov 17, 2010 at 4:03 PM, Frederiko Costa <frederiko@gmail.com> wrote:
True. However, I was just assuming that Postgres was running on default ports. If not, you could also probe in port ranges or even probe the network for open ports to have an idea and get closer. It might be faster option if software such as Spiceworks is not being used.

Spiceworks looks a good option too.

~Fred


On Wed, Nov 17, 2010 at 12:56 PM, Scott Whitney <scott@journyx.com> wrote:
That only works in the event that you have PG listening on port 5432.

A product like Spiceworks will provide much more detail, presuming you have the IT credentials to talk to the machines.


nmap is the way to go. Try to scan for port 5432 in a range of IP of your
LAN.

~Fred
Linkedin profile: http://www.linkedin.com/in/frederikocosta


On Sun, Nov 14, 2010 at 8:52 AM, ojas dubey <ojas.dubey@gmail.com> wrote:

> Hi,
>
> I wanted to know if there is a way to get the hostnames of all the systems
> running PostGres DB servers on a local network on Windows (XP/Vista/7) using
> JDBC or any other Java API ?
>
>
> Regards,
> Ojas
>






pgsql-admin by date:

Previous
From: bricklen
Date:
Subject: Re: unknown log messages
Next
From: Alejandro Brust at federacion
Date:
Subject: saludos y consulta