title: Reverse IP domain check script
body: <p>I wonder if there is a way to build a automated script (doesnt matter if its perl, bash or php) to find out what are the domains hosted on a certain ip.</p>
  
  <p>I'm trying to do something like the <em>Reverse IP Domain Check</em> on <a href="http://www.yougetsignal.com/tools/web-sites-on-web-server/" rel="nofollow">yougetsignal.com</a>.</p>
  
  <p>A friend of mine helped me with this, but it doesn't find the hosted domains given a list of server addresses; instead it just gets the host of the IP address.</p>
  
  <p>Here is the PHP code I have written</p>
  
  <pre><code>&lt;?php
  
  $file    = fopen("71", "r");
  $ip_file = fopen('iphosts', 'w');
  $ip_add  = fopen('ip_add', 'w');
  
  $i = 1;
  
  while ( ! feof($file) ) {
  
      $host = fgets($file);
      $host = rtrim($host);
  
      echo "\n";
      echo "Connecting..." . $host;
      echo "\n";
  
      $host_name = gethostbyaddr( $host );
      if ( !empty( $host_name ) &amp;&amp; $host != $host_name ) {
          fwrite($ip_file, $host_name."\n");
      } else {
          fwrite($ip_add, $host_name."\n");
      }
  
      echo " Done \n";
      $i++;
  }
  
  fclose($file);
  fclose($ip_file);
  fclose($ip_add);
  
  
  exit(0);
  </code></pre>