how to get a list of all the hosts on the intranet around my workstation?

P

Phlip

Yes, pythonistas, sometimes I even amaze myself with the quality of
question that a computer scientist with a 25 year resume can ask
around here...

In my defense, a Google search containing "intranet host" will fan out
all over the place, not narrow on what I actually need.

The Use Case is a user wants to ping a nearby host, and I provide a
list of nearby hosts for the user to pick from. Nothing else. Hosts on
the outernet need not apply.

pydhcplib? Shell to a DHCP utility? Ping every server in a range
around my own?
 
C

Chris Angelico

pydhcplib? Shell to a DHCP utility? Ping every server in a range
around my own?

I'd say there's several imperfect options, and no perfect ones.

1) DHCP, which hosts may or may not be using.
2) DNS - look up a list of the hosts within a (sub)domain.
3) Send out a broadcast ping and hope they all respond.

If you have full control, I would recommend the second. You could even
cheat by reading a file from /etc/bind or similar.

Depending on what you're trying to do, this could either be wholly
impractical, or an easy solution to an otherwise-difficult problem.

ChrisA
 
E

Emile van Sebille

pydhcplib? Shell to a DHCP utility? Ping every server in a range
around my own?

I'd say there's several imperfect options, and no perfect ones.

1) DHCP, which hosts may or may not be using.
2) DNS - look up a list of the hosts within a (sub)domain.
3) Send out a broadcast ping and hope they all respond.[/QUOTE]

Or try nmap and parse it's results.

Emile
 
T

Thomas Jollans

Yes, pythonistas, sometimes I even amaze myself with the quality of
question that a computer scientist with a 25 year resume can ask
around here...

In my defense, a Google search containing "intranet host" will fan out
all over the place, not narrow on what I actually need.

The Use Case is a user wants to ping a nearby host, and I provide a
list of nearby hosts for the user to pick from. Nothing else. Hosts on
the outernet need not apply.

pydhcplib? Shell to a DHCP utility? Ping every server in a range
around my own?

The obvious solution would be a broadcast ping. However, most hosts will
hot respond to a broadcast ping.

If every host in the network uses DHCP (and you are certain that they
all do), you can query the DHCP server — it should have a list of
active/recent hosts.

Chris mentioned DNS — that may be the most elegant solution, assuming
every host has a (registered) name.

If the network is populated only by Windows machines, you can use the
Windows name resolver. If it is populated only by zeroconf-aware
machines (modern Macs, most modern Linux PCs, Windows PCs with Apple
Bonjour installed), then you can use multicast DNS.

In the end, there is only one way to get all active machines: Ping
everyone on the subnet. You can get the local IP address and netmask
(don't ask me how), and ping every host on the subnet one-by-one. There
are tools that do this (though I can't name one off the top of my head).
This will only miss those hosts that don't respond to pings. (and even
they may be detected by trying to open other ports)

On a homogeneous network, query the infrastructure that is present. If
the network may contain "odd" machines that don't use DHCP, or something
like that, you'll have to ping the lot.
 
C

Chris Angelico

On 7/16/2011 9:52 AM Chris Angelico said...

Or try nmap and parse it's results.

Or that, which has the same risk as #3 - basically it means doing some
network traffic to find what systems are around. It's still imperfect,
because it's likely that a down server will simply not be in the list
- someone could go through all the hosts on the list, ping them all,
and think that everything's fine.

But yes, nmap is more reliable than a broadcast ping, for what it's worth.

ChrisA
 
C

Chris Angelico

In the end, there is only one way to get all active machines: Ping
everyone on the subnet.

But that will list everyone who's _currently_ active; it won't list
everyone who _ought to be_ active. However, the OP was slightly
ambiguous:

The Use Case is a user wants to ping a nearby host, and I provide a
list of nearby hosts for the user to pick from. Nothing else. Hosts on
the outernet need not apply.

Does "ping a nearby host" simply mean that you want to ping someone
who's up, as a means of testing the client's own network connection?
Or are you seeking to list all servers and know if any has gone down?

If the former, it's quite easy. In fact, you could just hard-code a
few IPs of key routers and/or servers, and ping those, much more
easily than listing hosts.

ChrisA
 
M

Michael Hrivnak

A host on your network is likely to have a default gateway (aka
default route). That should be a reliable thing to ping.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top