Need to check all users travelling my web site for their IP address and then see if any other connection via their IP range is seen.

I thought I could do this by s/// the final octet of the IP and then check to see if it exists already, but that logic fails, of course, because it'd fail even if the same IP appeared twice.

I guess I'll need to store the entire IP address and see if an IP with a different last octet is seen. This must be really easy but the logic is just playing with my head.

I think I will be using MYSQL to store all the information (ips, timestamps, etc).

What I really want to do is check to see if the user's IP was seen already using a bot (meaning the same IP range but different numbers at the end) and then block them if two or more users on the same IP range were seen in the past 1 minute.

Any helpful pointers on what data to store to compare with and everything would be great. If this would be easier to do using DB_File, I think I'd rather use that instead.


In reply to blocking last ip octet by iluvperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.