0

This is my program to display the ip address of a system.

IPHostEntry ip = Dns.GetHostEntry(Dns.GetHostName());
IPAddress[] IPaddr = ip.AddressList;
for (int i = 0; i < IPaddr.Length; i++)
{
    Console.WriteLine("IP Address {0}: {1} ", i, IPaddr[i].ToString());
}

This displays the below output:

IP Address 0: fe80::90da:c637:d34a:c8a3%2
IP Address 1: 10.0.2.6

Why does this display two values? Isn't the second one the real ip address?

hnefatl
  • 5,860
  • 2
  • 27
  • 49
the_coder_in_me
  • 143
  • 3
  • 15
  • 1
    Machines can have multiple IP addresses. The first one listed here is an IPV6 address, the second is an IPV4 - machines can have any number of either kind. – hnefatl Nov 16 '17 at 19:41
  • Potential duplicate https://stackoverflow.com/questions/6803073/get-local-ip-address – mrkg Nov 16 '17 at 19:45

0 Answers0