DNS Record Stress Check

Discussion in 'Server Stuff' started by Mun, May 23, 2014.

  1. Mun

    Mun Administrator

    Here is the code below of a PHP app I wrote for the purposes of stress testing a group of DNS servers to see if they would send back a wrong result. You as you like.

    Code:
    <?php
    /*
     Author:  Cameron Munroe
     Website:  http://www.cameronmunroe.com
     Version:  1.0
     Description:  This lovely application checks a DNS address
     - against an IP address that you specify to check to see if
     - you have failed lookups.
     How To Exec:  php nameoffile.php
     Deb Libs:  apt-get install php5 php5-cli
    */
    // ----------------------------------------------------
    //  Main config
    // ----------------------------------------------------
    // Set the DNS address you wish to check.
    $dnsadd='ldap.prps.org';
    
    // Set the IP address you expect to recieve.
    $ipadd='192.168.230.188';
    
    
    // -----------------------------------------------------
    //  Core App
    // -----------------------------------------------------
    
    
    $i = 0;
    $r = 0;
    $w = 0;
    $c = 0;
    do {
       $result = gethostbyname($dnsadd);
       $i++;
       if ($result != $ipadd) {
         echo "\n" . "Error: " . $result . ' Is not equal to ' . $ipadd;
         $w++;
       }
       else {
         $r++;
       }
       if ($i == 1000) {
         $c++;
         echo "\n" . 'right/wrong answers ' . $r . '/' . $w . ' and this is out of ' . ($c * $i) . ' times';
         $i = 0;
       }
       usleep(1000);
    } while (1 == 1);
    echo 'done';
    
    // -----------------------------------------------------
    //  End of Core App
    // -----------------------------------------------------
    
    
    
    ?>
    
    

    ------------------------------------------------------
    Same Script In python (no guarantees)
    ------------------------------------------------------

    Code:
    #!/usr/bin/python
    import socket
    import time
    VAR_i = 0
    VAR_r = 0
    VAR_w = 0
    VAR_c = 0
    VAR_i_to = 1000
    VAR_addr = "ldap.prps.org"
    VAR_addr_right = "192.168.230.188"
    while 1 > 0:
       VAR_i +=1
       try:
         VAR_result = socket.gethostbyname(VAR_addr)
       except:
         pass
       if VAR_addr_right == VAR_result:
         VAR_r +=1
       else:
         VAR_w +=1
         print("The Wrong address was seen for: " + str(VAR_addr) + ". We saw: " + str(VAR_result))
       if VAR_i >= VAR_i_to:
         VAR_c +=1
         print("right/wrong:: " + str(VAR_r) + " / " + str(VAR_w))
         VAR_i = 0
       time.sleep(0.001)
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice