IP Address of Network interface Card

  • Thread starter Thread starter Maanu
  • Start date Start date
M

Maanu

Hi,

How can I get the IP address of a network card in my machine? I have the
NetworkInterface object corresponding to that card

Thanks!
 
How can I get the IP address of a network card in my machine? I have the
NetworkInterface object corresponding to that card

Some old code from the shelf:

using System;
using System.Net.NetworkInformation;

namespace EE
{
public class MainClass
{
public static void Main(string[] args)
{
NetworkInterface[] nics =
NetworkInterface.GetAllNetworkInterfaces();
foreach(NetworkInterface nic in nics)
{
if(nic.GetPhysicalAddress().ToString().Length > 0 &&
nic.GetIPProperties().UnicastAddresses.Count > 0)
{
Console.WriteLine(nic.GetPhysicalAddress() + " " +
nic.GetIPProperties().UnicastAddresses[0].Address);
}
}
}
}
}

Arne
 
Back
Top