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).
Asked
Active
Viewed 1.6k times
3
-
1Possible duplicate of [How to get IP of all hosts in LAN?](http://stackoverflow.com/questions/4042789/how-to-get-ip-of-all-hosts-in-lan) – Chawin Nov 24 '15 at 07:53
-
1…or this http://stackoverflow.com/questions/6803073/get-local-ip-address – Dmitry Bychenko Nov 24 '15 at 07:54
-
Possible duplicate of [How do I get a list of the active IP-addresses, MAC-addresses and NetBIOS names on the LAN?](http://stackoverflow.com/questions/90755/how-do-i-get-a-list-of-the-active-ip-addresses-mac-addresses-and-netbios-names) – TMichel Nov 24 '15 at 07:58
2 Answers
6
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.

Mohit S
- 13,723
- 6
- 34
- 69
-
Thnq..in comment all ip address in lan how can i get that in richtextbox..Kindly help! – Vijay Anand Nov 24 '15 at 10:23
1
If you already know the hostnames (as your question implies), you can use the Dns.GetHostAddresses
method to translate them to IP addresses.

Luaan
- 62,244
- 7
- 97
- 116