Based on this post I have decided make some program which able to detect weather IP is a part of some network (in this case UA-IX network) or not.
Speaking about UA-IX, from wikipedia we know:
The Ukrainian traffic exchange network (UA-IX) (Ukrainian: Українська мережа обміну інтернет-трафіком) is an Internet exchange point that was established in Kiev, the capital of Ukraine, on July 2000 and is the daughter company of Ukrainian Internet Association. Companies that established Ukrainian traffic exchange network are major Ukrainian businesses that work expanding Ukrainian Internet market.
Here the list of all networks which belongs to UA-IX net. Download it to your machine and save as ua-list.txt.
Content of file. We have some networks list here:
$ head -3 ua-list.txt 8.8.4.0/24 8.8.8.0/24 62.16.0.0/19
Here is the script:
$cat uaix.pl
#!/usr/local/bin/perl
# Written by Andrii Grytsenko 2010
# PP: http://andriigrytsenko.net
use POSIX;
use strict;
sub dec2bin {
my $hex = shift;
my $pack = unpack("B32",pack("N",$hex));
my $pack = substr($pack,-8);
return $pack;
}
my $bin_ip;
$bin_ip .= dec2bin($_) foreach (split(/\./,$ARGV[0]));
open(IP, "<$ARGV[1]");
while(){
chomp();
my ($ip,$net_mask) = split(/\//,$_);
$net_mask = 24 if (!defined($net_mask));
my $bin_network;
$bin_network .= dec2bin($_) foreach (split(/\./,$ip));
my $net_net_part = substr($bin_network,0,$net_mask);
my $net_ip_part = substr($bin_ip,0,$net_mask);
if ( $net_net_part == $net_ip_part) {
print "IP $ARGV[0] belong to network $_\n";
exit;
}
}
print "IP $ARGV[0] is not part of UA-IX\n";
close(IP);
To run the script:
$ perl uaix.pl [ip_addr] [path/to/ua-list.txt]
For example:
$ perl uaix.pl 72.14.228.156 ua-list.txt IP 72.14.228.156 belong to network 72.14.192.0/18
There is also some ways to use script on your own… You can use your list of networks to detect ;)