[Tutor] IP-range

Øyvind python at kapitalisten.no
Thu Aug 31 16:11:37 CEST 2006


Hello.

I have a database where I have some IP-ranges. Then I have some logs over
IPs from customers and need to connect the two.

So, for example:

Range 1:
123.132.122.4-123.132.122.255

How do I check if IP 123.132.122.58 is a part of that? I have thought
about 4 if statements:

split(.)
if ip[0] in iprange_from[0] and iprange_to[0]:
  if ip[1] in iprange_from[1] and iprange_to[1]:
    if ip[2] in iprange_from[2] and iprange_to[2]:
      if ip[3] in iprange_from[3] and iprange_to[3]:
        then ok

But that seems silly. Is there some better way?

Thanks in advance


-- 
This email has been scanned for viruses & spam by Domenebutikken - www.domenebutikken.no
Denne e-posten er sjekket for virus & spam av Domenebutikken - www.domenebutikken.no



More information about the Tutor mailing list