Collecting IP range

David Murmann david.murmann at rwth-aachen.de
Mon Jan 30 23:33:06 EST 2006


yawgmoth7 schrieb:
> Hello, I'm sure that this has been discussed before, but I have a
> question. I have written a few port scanners, banner grabbers in the
> past and have never found a good way to get a range of IP's.
> Obviously, in my opinion the best and simplest way to do somethign
> like and simple port scanner is to do something like:
> 
> <code>
> for ips in range(startip,endip):
>      <do blah>
> 

you might want to take a look at IPy:

  http://c0re.23.nu/c0de/IPy/

iterating over ip-address ranges is very easy there:

      >>> ip = IP('127.0.0.0/30')
      >>> for x in ip:
      ...  print x
      ...
      127.0.0.0
      127.0.0.1
      127.0.0.2
      127.0.0.3

--
David.



More information about the Python-list mailing list