Re: Re: a question...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just want to point out that public IPs are no longer given out as
Class A, B, and C networks, but based on CIDR.  You can use rwhois to
figure out who has use of a certain subnet and what the range of it is.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Daniel Brown wrote:
> On Wed, Jul 23, 2008 at 12:10 PM,  <payne@xxxxxxxxxxxxxxxxxxx> wrote:
>   
>> Yes, sorry. I have a database that records ip of attacks on a customer
>> server, what I like to do get a count so that I can see what subnet is
>> doing the major of the attacks.
>>
>> select ip from ipslimit 10;
>> +-----------------+-----------+
>> | ip              | count(ip) |
>> +-----------------+-----------+
>> | 83.117.196.206  |         1 |
>> | 85.17.109.28    |         1 |
>> | 125.138.96.19   |         1 |
>> | 89.110.148.253  |         1 |
>> | 192.168.105.10  |         1 |
>> | 200.170.124.72  |         1 |
>> | 201.116.98.214  |         1 |
>> | 202.168.255.226 |         1 |
>> | 203.89.243.158  |         1 |
>> | 210.245.207.217 |         1 |
>> +-----------------+-----------+
>> 10 rows in set (0.00 sec)
>>     
>
>     Okay, this would have to be done in code, and isn't a MySQL issue.
>  Presuming you're using PHP, I'm going to also copy this message to
> the PHP General mailing list, Payne, so that others can benefit from
> it in the archives as well.  If you're not already subscribed and
> would like to follow along with the thread, please send a blank
> message to php-general-subscribe@xxxxxxxxxxxxxx
>
>     To get the Class C on that, here's a simple function you can use:
>
> <?php
> function get_subnet($ip) {
>         return substr($ip,0,strrpos($ip,'.'));
> }
> ?>
>
>     As a quick illustration of how it works, here's an example script
> (to use MySQL, just replace the $ips array with your <?php $row =
> mysql_fetch_array($result); ?> or similar line):
>
> <?php
> $ips = array('192.168.0.0','10.0.0.1','127.0.0.1','216.37.159.240','99.99.99.99','127.0.0.2','192.168.1.1','10.0.0.0','192.168.0.1','192.168.0.150');
>
> function get_subnet($ip) {
>         return substr($ip,0,strrpos($ip,'.'));
> }
>
> foreach($ips as $ip) {
>         echo $ip."'s Class C is ".get_subnet($ip)."\n";
> }
> ?>
>
>
>   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux