Re: all ip addresses of machines in the local network



Amit Khemka wrote:
On 8/24/06, Amit Khemka <khemkaamit@xxxxxxxxx> wrote:
On 23 Aug 2006 21:46:21 -0700, damacy <wegein@xxxxxxxxx> wrote:
hi, sandra.

no, it's not as complicated as that. all i want to do is to load a
database onto different machines residing in the same network. i hope
there is a way doing it. or perhaps i have a poor understanding of how
networks work.


I expect that you would know the IP range for your network. Then you
can simply 'ping' each IP in the range to find wether its alive.
Moreover by your description I guess you would actually want to find
all machines in your network that run a particular network service, to
allow you to "distribute the database". In such case you can use
"nmap" with -p option, to find all the machines which are listening on
the particular port.

hth,
amit.
It seems that I am not too busy, so here is a code which may work with
a few tweaks here and there:
_________________________________________________________________________
import os
# base and range of the ip addresses
baseIP = "10.0.0."
r = 6
interestingPort = 22 # port that you want to scan
myIPs = []

for i in range(r):
ip = baseIP+str(i) # It may need some customization for your case
print "scanning: %s" %(ip)
for output in os.popen("nmap %s -p %s" %(ip,
interestingPort)).readlines():
if output.__contains__('%s/tcp open'
%interestingPort): # i guess it would be tcp
myIPs.append(ip)
__________________________________________________________________________
print myIPs


hth,
amit.
--
----
Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.

thank you for your code. i had a look at nmap and i think it's got some
cool features in it. however, i found it quite slow in my case as it
takes extra time to process the output.

in my program so far, multiple threads (255 threads in total) spawned
at once with each one of them trying to call socket.gethostbyaddr(ip)
function. i.e. if exception thrown, no machine found. i used .join() to
wait for the threads to terminate. it's fully working however the
problem is that it's too slow. it takes approx. 14 seconds to process
(i tried using 'ping' but it's even slower.).

my question is.. is there a way to improve performance of the program
if i know what the port number would be? in my case, the port number
will always be constant although i have no clue on what ip addresses
would be (that's the reason all of 255 different addresses must be
tested).

i tried the same function with the port number specified,
gethostbyaddr(ip:portno), but it is even 10-second slower than using
the same function without a port number specified (i.e. approx. 25
seconds to complete).

could anyone think of a better way of solving this problem?

regards, damacy

.



Relevant Pages

  • Re: Update: UDP 770 Potential Worm
    ... > I still believe that the packets may be the result ... with the goal of knocking machines ... the network immediately after the 'attack', ... destined to port if you haven't sniffed it somehow? ...
    (Incidents)
  • Re: A Lot of Traffic on Network
    ... have you checked out the machines that are ... bigger switches and hubs i have seen there is usually a port activity light ... > Actually our network administrator quit. ...
    (microsoft.public.win2000.security)
  • RE: Blocking SMT Connections by clients
    ... > worthy of a blacklisting. ... The network is regularly ... > to construct a packet filter to do this - block any machines INSIDE ... > the network from making TCP connections to REMOTE hosts on port 25.. ...
    (microsoft.public.isa.configuration)
  • Re: security question
    ... address may be just a NAT for a larger network behind it, ... Unisite Internet Presence Provider ... As long as you open your port 22 to the world, ... machines or networks that need the access. ...
    (linux.redhat)
  • Re: all ip addresses of machines in the local network
    ... Amit Khemka wrote: ... database onto different machines residing in the same network. ...
    (comp.lang.python)