|
-
June 1st, 2006, 07:32 PM
#1
get MAC and IP of my NIC card
I am trying to find the IP address associated with a particular NIC card. If a PC has more than 1 NIC card, then it can have more than 1 IP address.
So... given a particular IP address, how can I find the MAC (or NIC card) associated with that IP?
Here is what I have so far... its close, but not quite there.
Code:
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
//could have multiple MAC addresses
lstOutput.Items.Add("MAC : " + adapter.GetPhysicalAddress());
}
lstOutput.Items.Add("Host Name : " + Dns.GetHostName());
IPAddress[] hosts = Dns.GetHostAddresses(Dns.GetHostName());
foreach (IPAddress address in hosts)
{
//could have multiple IPs (how do I associate with the correct MAC?)
lstOutput.Items.Add("Address : " + address.ToString());
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|