OpenNIC fastest DNS server lister


This script prints a list of OpenNIC public DNS servers sorted by the shortest ping time (average of 10 tries).

Requirements



The script

Update 2012-05-21: now it shows if a server has timed out

CkOpenNICDNSSpeed.php (line 1)
  1. #!/usr/bin/php -q
  2.  
  3. <?php
  4.  
  5. /*
  6.         CkOpenNICDNSSpeed - a script for finding the fastest OpenNIC DNS servers
  7.         Copyright (C) 2012 Ɓukasz "Cyber Killer" Korpalski
  8.  
  9.         This program is free software: you can redistribute it and/or modify
  10.         it under the terms of the GNU General Public License as published by
  11.         the Free Software Foundation, either version 3 of the License, or
  12.         (at your option) any later version.
  13.  
  14.         This program is distributed in the hope that it will be useful,
  15.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.         GNU General Public License for more details.
  18.  
  19.         You should have received a copy of the GNU General Public License
  20.         along with this program.  If not, see <http://www.gnu.org/licenses/>.
  21. */
  22.  
  23. $dnsaddr=array(         //opennic ipv4 dns servers as of 2012-03-27
  24.         "66.244.95.20"=>"0",
  25.         "74.207.247.4"=>"0",
  26.         "216.87.84.211"=>"0",
  27.         "64.0.55.201"=>"0",
  28.         "69.164.196.21"=>"0",
  29.         "72.232.162.195"=>"0",
  30.         "205.185.120.143"=>"0",
  31.         "184.154.13.11"=>"0",
  32.         "128.173.89.246"=>"0",
  33.         "68.68.18.197"=>"0",
  34.         "74.212.172.171"=>"0",
  35.         "108.174.52.189"=>"0",
  36.         "89.16.173.11"=>"0",
  37.         "192.121.121.14"=>"0",
  38.         "192.121.86.100"=>"0",
  39.         "109.124.157.251"=>"0",
  40.         "27.110.120.30"=>"0",
  41.         "109.235.51.12"=>"0",
  42.         "195.46.245.59"=>"0",
  43.         "217.171.190.12"=>"0",
  44.         "92.243.8.139"=>"0",
  45.         "82.237.169.10"=>"0",
  46.         "178.63.26.173"=>"0",
  47.         "178.63.26.174"=>"0",
  48.         "83.223.73.116"=>"0",
  49.         "217.79.186.148"=>"0",
  50.         "178.63.26.172"=>"0",
  51.         "217.6.34.47"=>"0",
  52.         "217.6.34.48"=>"0",
  53.         "78.138.97.33"=>"0",
  54.         "62.146.14.194"=>"0",
  55.         "89.185.225.28"=>"0",
  56.         "67.212.90.199"=>"0",
  57.         "66.206.229.62"=>"0",
  58.         "216.167.252.195"=>"0",
  59.         "216.167.252.197"=>"0",
  60.         "74.115.206.100"=>"0",
  61.         "202.83.95.227"=>"0",
  62.         "85.126.4.170"=>"0"
  63.         );
  64.  
  65. print("Pinging DNS servers, please wait...\n\n");
  66.  
  67. $i=0;
  68.  
  69. foreach($dnsaddr as $curip=>$time)
  70. {
  71.         exec("ping -q -c 10 ".$curip."|tail -n 1|cut -d/ -f5",$temp);
  72.         if($temp[$i]!="")
  73.         {
  74.                 $dnsaddr[$curip]=$temp[$i];
  75.         }
  76.         else
  77.         {
  78.                 $dnsaddr[$curip]="timeout";
  79.         }
  80.         $i++;
  81. }
  82.  
  83. asort($dnsaddr);
  84.  
  85. print("DNS server\tAverage ping\n");
  86. foreach($dnsaddr as $curip=>$time)
  87. {
  88.         print($curip."\t".$time."\n");
  89. }
  90.  
  91. ?>


Just click grab to save the file, or copy&paste it yourself to your favorite editor. Remember to add executable permissions.

License


This program is under the GNU GPL v3 or later.


 
CategoryProjekty
Comments [Hide comments/form]
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki