Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Storing and searching sets of IP address ranges

by DrHyde (Prior)
on Jul 08, 2010 at 10:24 UTC ( [id://848666]=note: print w/replies, xml ) Need Help??


in reply to Storing and searching sets of IP address ranges

You want Net::CIDR, specifically the cidrlookup function. Pass it an address and a (list of) CIDR blocks and it'll tell you whether the address is in any of the blocks.

If your address range doesn't match a single CIDR block, (eg it's 192.168.32.45 to 192.168.255.255) then you can use the range2cidr function to generate the appropriate list of CIDR blocks.

It should work for both IPv4 and IPv6.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-16 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found