title: Get all IPs assigned to a server
body: <p>I came across a code snippet on this answer: <a href="https://stackoverflow.com/questions/858341/console-application-ip-address/">Get IP address in a console application</a></p>
  
  <pre><code>using System; 
  using System.Net; 
  
  
  namespace ConsoleTest 
  { 
      class Program 
      { 
          static void Main() 
          { 
              String strHostName = string.Empty; 
              // Getting Ip address of local machine... 
              // First get the host name of local machine. 
              strHostName = Dns.GetHostName(); 
              Console.WriteLine("Local Machine's Host Name: " + strHostName); 
              // Then using host name, get the IP address list.. 
              IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); 
              IPAddress[] addr = ipEntry.AddressList; 
  
              for (int i = 0; i &lt; addr.Length; i++) 
              { 
                  Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString()); 
              } 
              Console.ReadLine(); 
          } 
      } 
  } 
  </code></pre>
  
  <p>This code works fine when I run it on locally to get the IP addresses of my computer. What I'm trying to do is use the code to get the IP addresses on a server on my network. So basically I tried replacing strHostName = Dns.GetHostName(); with strHostName = "myServerName"; but it only returns one IP. When I run the program on the server itself I get all of the IPs assigned to that server. The goal is to run the program on my computer, read server names from a database table to get the IP addresses on over 100 servers. I'm trying to avoid having to log on to each server and run the program on each one of the servers to get the IP addresses.</p>
  
  <p>Interesting enough the code works fine for "www.google.com" - is this server related or a security issue?</p>
  
  <p>Before I can start getting data from the database I need to get the code to work for one server :) Hope that explains it better. Thanks!</p>