[Python] Finding connected IP addresses

Bob Miller kbob at jogger-egg.com
Mon Oct 16 11:26:31 PDT 2006


Timothy Bolz wrote:

> I'd like to find the ip addresses of the computers on my network
> with python.

Take a look at nmap.  It scans a range of IP addresses and reports
which ones respond.  (Nmap is not Python, sorry.)

> Then  I would write a little program which polls what computers which are 
> logged in and displays them like an IM who is on box.

Take a look at the obsolete finger and rwho protocols.  Those are both
designed to show who's logged in on which boxes.

Note that both protocols are relics from a time when network security
was much more lax.  Don't run them on a publicly accessible network,
nor on one where you wouldn't trust all the users with your root
password.

Ubuntu has packages for the original rwho and rwhod programs from
Berkeley.  It has dozens of finger clients and servers to choose from,
and I don't have a recommendation.

> My connection is using DHCP so it can change.

You can configure your DHCP server so that it always binds a
particular MAC address to a particular IP address.  Then your hosts'
IP addresses won't change.

> I've tried it and it give the localhost number.  I'll keep on
> looking I thought one of you would know how to get the other
> addresses short of pinging

How about /sbin/ifconfig?

I apologize for the non-Python nature of my answers.

-- 
Bob Miller                              K<bob>
                                        kbob at jogger-egg.com


More information about the Python mailing list