How to get all IP address on a LAN ?
I have no idea how to get all IP address on a LAN.
Welcome to devnet forum
Probably you may have to elaborate a bit more what you are trying to do.
Sorry, I want to get a list of IP address of all computers connected to a same lan. But I don't know what method I can use in Qt.
AFAIK there is no support of Qt for your task. I would assume that you require the support of your LAN access point for providing all IP addresses. For instance a router modem may tell you all IP addresses connected.
thanks. may be i need to find a alternative method to fix it.
There is no sure way to achieve it. If computers are in DHCP you have to deal with the DHCP server to get the assigned addresses, but someone could have used a fixed ip address or could have disconnected before the lease expired. You can try to ping a broadcast, but someone could not reply to the ping. The only solution is to rely on a service on each machine announcing to you or that you can poll.
You can use ARP , which is what computers in the same subnetwork use to communicate.
Follow "These instructions":http://www.windowsitpro.com/article/monitoring-and-analysis/how-can-i-get-a-list-of-mac-to-ip-addresses-on-the-network to see how it work, but if you want to do it using Qt, you need to create thes packets yourself. Or you can wrap call the script on each OS to get something portable.
[quote author="aureshinite" date="1325459482"]You can use ARP [/quote]
Arp will work as a cache, so it is not safe either to query via arp other network cards.
[quote author="fluca1978" date="1325489013"]
Arp will work as a cache, so it is not safe
Can you explain me how it is not safe?
If there is a functioning and trusted (ie it doesn't send garbage) computer in your LAN, then you can definitely see its address in the ARP cache. The article use ping as a fast way of using it, but ARP itself has multiple way of finding hosts. For example an ARP probe which is usually for testing address conflict can be use. You send it, and you just need to collect hosts details from packets responses. Note that this can also be done from the ping to the broadcast address.
At the length of my knowledge, DHCP is only use between a client and DHCP servers. It cannot obtain information about other clients using DHCP protocol.
The idea is : You need to use broadcast in some way. Either with ping, either with ARP. Not with DHCP.
One thing : a router never retransmit an ARP outside his sub-network. So if your network has an hierarchy of routers, use ping.
There is no reliable way to determine all hosts in a LAN. Point.
There are many means of guessing your neighbors, each with its own advantages and drawbacks. But you will never be sure you get all hosts.
A dhcp server knows assigned addresses. The problem is the host could have been disappeared before the lease expires or it could have a static address. In both cases, the dhcp server will not know enough about the client.
An arp discovering is much more complicated than a ping broadcast. None is more sure than the other, since an host can avoid replying a ping or can use arp poisoning.
If you pass a router you are outside your network, so there is no advantage in using ping with respect to arp. Moreover, each time you pass a router you are calling for other troubles, since the router could also filter packets.
As I said in my previous post, and as Volker stated, there is no way to discover hosts on a network. Or better, the only way is to sniff traffic thru a mirrored port over a switch.
You can find out the Ip address of your connection and not the ip address of all computers connected through the same LAN...I can provide you with some tips to find your IP address..
Press the Windows key and R button at the same time
Type cmd in the run tab which is opened and press OK
Type ipconfig in the command prompt dialog box