Jump to content

Need help figuring out how to query data efficiently


Strahan

Recommended Posts

Howdy.  I have a database that has a list of "targets".  Computer names, user names and IP addressing.  If the current system that the script runs on matches the database for one of those targets, it runs that record.  Now the computer & user names I have working fine.  The IP I used to have working, but I hit a roadblock.  I wanted to be able to do wildcards, like grab all IPs in specific subnets.  I made it able to accept an IP like 192.168.0.* for example.  However, I neglected to take into account small subnetted ranges..  like 192.168.1.192 with a CIDR of /28.  That means only .192 - .207 would fall within that network.

 

Soooo...  I have fields like this in the database:

192.168.1.192/28

10.0.0.102/32

 

..and the script knows that my current IP for example is 192.168.1.195.  Short of looping through every single record that has an IP and testing it against my current IP, is there an efficient way to match an IP to a network designation like that? 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.