Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9629 > unrolled thread

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

Started byPhlip <phlip2005@gmail.com>
First post2011-07-16 09:31 -0700
Last post2011-07-16 16:01 -0400
Articles 8 — 6 participants

Back to article view | Back to comp.lang.python


Contents

  how to get a list of all the hosts on the intranet around my workstation? Phlip <phlip2005@gmail.com> - 2011-07-16 09:31 -0700
    Re: how to get a list of all the hosts on the intranet around my workstation? Chris Angelico <rosuav@gmail.com> - 2011-07-17 02:52 +1000
    Re: how to get a list of all the hosts on the intranet around my workstation? Emile van Sebille <emile@fenx.com> - 2011-07-16 11:04 -0700
    Re: how to get a list of all the hosts on the intranet around my workstation? Thomas Jollans <t@jollybox.de> - 2011-07-16 20:15 +0200
    Re: how to get a list of all the hosts on the intranet around my workstation? Chris Angelico <rosuav@gmail.com> - 2011-07-17 04:19 +1000
    Re: how to get a list of all the hosts on the intranet around my workstation? Chris Angelico <rosuav@gmail.com> - 2011-07-17 04:27 +1000
    Re: how to get a list of all the hosts on the intranet around my workstation? Christian Heimes <lists@cheimes.de> - 2011-07-16 21:59 +0200
    Re: how to get a list of all the hosts on the intranet around my workstation? Michael Hrivnak <mhrivnak@hrivnak.org> - 2011-07-16 16:01 -0400

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

FromPhlip <phlip2005@gmail.com>
Date2011-07-16 09:31 -0700
Subjecthow to get a list of all the hosts on the intranet around my workstation?
Message-ID<a872bea7-3920-44c4-8df2-e75cad47c5f2@p12g2000pre.googlegroups.com>
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?

--
  Phlip
  http://bit.ly/ZeekLand

[toc] | [next] | [standalone]


#9631

FromChris Angelico <rosuav@gmail.com>
Date2011-07-17 02:52 +1000
Message-ID<mailman.1115.1310835137.1164.python-list@python.org>
In reply to#9629
On Sun, Jul 17, 2011 at 2:31 AM, Phlip <phlip2005@gmail.com> wrote:
> 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

[toc] | [prev] | [next] | [standalone]


#9638

FromEmile van Sebille <emile@fenx.com>
Date2011-07-16 11:04 -0700
Message-ID<mailman.1119.1310839350.1164.python-list@python.org>
In reply to#9629
On 7/16/2011 9:52 AM Chris Angelico said...
> On Sun, Jul 17, 2011 at 2:31 AM, Phlip<phlip2005@gmail.com>  wrote:
>> 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.

Or try nmap and parse it's results.

Emile


>
> 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

[toc] | [prev] | [next] | [standalone]


#9641

FromThomas Jollans <t@jollybox.de>
Date2011-07-16 20:15 +0200
Message-ID<mailman.1122.1310840120.1164.python-list@python.org>
In reply to#9629
On 07/16/2011 06:31 PM, Phlip wrote:
> 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.

[toc] | [prev] | [next] | [standalone]


#9642

FromChris Angelico <rosuav@gmail.com>
Date2011-07-17 04:19 +1000
Message-ID<mailman.1123.1310840400.1164.python-list@python.org>
In reply to#9629
On Sun, Jul 17, 2011 at 4:04 AM, Emile van Sebille <emile@fenx.com> wrote:
> On 7/16/2011 9:52 AM Chris Angelico said...
>>
>> 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.
>
> 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

[toc] | [prev] | [next] | [standalone]


#9644

FromChris Angelico <rosuav@gmail.com>
Date2011-07-17 04:27 +1000
Message-ID<mailman.1125.1310840828.1164.python-list@python.org>
In reply to#9629
On Sun, Jul 17, 2011 at 4:15 AM, Thomas Jollans <t@jollybox.de> wrote:
> 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:

On Sun, Jul 17, 2011 at 2:31 AM, Phlip <phlip2005@gmail.com> wrote:
> 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

[toc] | [prev] | [next] | [standalone]


#9647

FromChristian Heimes <lists@cheimes.de>
Date2011-07-16 21:59 +0200
Message-ID<mailman.1131.1310846388.1164.python-list@python.org>
In reply to#9629
Am 16.07.2011 21:13, schrieb Dan Stromberg:
> Some options:
> 
> 1) Broadcast ping
> 2) nmap the subnet, optionally with -P0
> 3) Check the arp cache (optionally after options 1, 2 or 4)
> 4) Unicast ping everything on the subnet in parallel - very effective, very
> fast, might want to do it with threads rather than subprocesses to avoid a
> load spike

5) arping - needs root permissions but works well inside a broadcast
domain. It can detect hosts that block ICMP echo reply, too.

Christian

[toc] | [prev] | [next] | [standalone]


#9648

FromMichael Hrivnak <mhrivnak@hrivnak.org>
Date2011-07-16 16:01 -0400
Message-ID<mailman.1132.1310846507.1164.python-list@python.org>
In reply to#9629
A host on your network is likely to have a default gateway (aka
default route).  That should be a reliable thing to ping.

Michael

On Sat, Jul 16, 2011 at 12:31 PM, Phlip <phlip2005@gmail.com> wrote:
> 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?
>
> --
>  Phlip
>  http://bit.ly/ZeekLand
> --
> http://mail.python.org/mailman/listinfo/python-list
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web