I am getting all system name connected in LAN network. I don't know how to get IP Address of all system name like (192.168.1.15).
-
1Possible duplicate of How to get IP of all hosts in LAN?– ChawinNov 24, 2015 at 7:53
-
1…or this stackoverflow.com/questions/6803073/get-local-ip-address– Dmitry BychenkoNov 24, 2015 at 7:54
-
Possible duplicate of How do I get a list of the active IP-addresses, MAC-addresses and NetBIOS names on the LAN?– TMichelNov 24, 2015 at 7:58
2 Answers
This might do the trick for you
foreach(NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
{
if(!ip.IsDnsEligible)
{
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
// All IP Address in the LAN
}
}
}
}
The Only drawback of this code is that the information returned by instances of UnicastIPAddressInformation
is not available for operating systems earlier than Windows XP.
-
Thnq..in comment all ip address in lan how can i get that in richtextbox..Kindly help! Nov 24, 2015 at 10:23
If you already know the hostnames (as your question implies), you can use the Dns.GetHostAddresses
method to translate them to IP addresses.