Get All IP Addresses on Machine

The DNS variants work across the network, but one DNS entry can have many IP addresses and one IP address can have many DNS entries.
More importantly, an address needn’t be bound to a DNS entry at all.

For the local machine try this:-

  foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
  {
    Console.WriteLine("Name: " + netInterface.Name);
    Console.WriteLine("Description: " + netInterface.Description);
    Console.WriteLine("Addresses: ");
    IPInterfaceProperties ipProps = netInterface.GetIPProperties();
    foreach (UnicastIPAddressInformation addr in ipProps.UnicastAddresses)
    {
      Console.WriteLine(" " + addr.Address.ToString());
    }
    Console.WriteLine("");
  }

Leave a Comment