Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Quickly determine which IP range an IP belongs to.

by ikegami (Patriarch)
on Nov 30, 2010 at 01:59 UTC ( [id://874415]=note: print w/replies, xml ) Need Help??


in reply to Quickly determine which IP range an IP belongs to.

  1. Convert the addresses and masks into 32-bit numbers or 4-byte strings.
  2. For each range,
    1. "And" ("&") the specified IP with the range's mask
    2. If the result is the start IP of the masks's range, the address is in that range.

If you have lots of ranges, you could group them by mask.

$user_lookup{inet_aton($mask)}{inet_aton($start_addr)} = $user_num;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://874415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found