views:

81

answers:

5

I'm interested in finding a way to enumerate all accessible devices on the local network, regardless of their IP address. For example, in a 192.168.1.X network, if there is a computer with a 10.0.0.X IP address plugged into the network, I want to be able to detect that rogue computer and preferrably communicate with it as well. Both computers will be running this custom software.

CLARIFICATION: We want to handle the situation where we do not know what the single computer's IP address is and cannot guarantee that it's on any particular subnet. All we know is that the computer is physically plugged into the same switch and the computer has a static IP assigned to it (but that IP could be anything).

We have remote access to one computer on the network (say, 192.168.1.30), and we want to be able to communicate with all other computers on the network, regardless of whether their static IP is set to 192.168.1.x, 10.0.0.x, 10.45.21.7, etc.)

I realize that's a vague description, and a full solution to the problem would be lengthy, so I'm really looking for help finding the right direction to go in ("Look into using class XYZ and ABC in this manner") rather than a full implementation.

The reason I want this is that our company ships imaged computers to thousands of customers, each of which have different network settings (most use the same IP scheme, but a large percentage do not, and most do not have DHCP enabled on their networks). Once the hardware arrives, we have a hard time getting it up on the network, especially if the IP scheme doesn't match, since there is no one technically oriented on-site. Ideally, I want to design some kind of console to be used from their main workstation which looks out on the network, finds all computers running our software, displays their current IP address, and allows you to change the IP.

EDIT: Unless I've misunderstood something, I don't think I can use the broadcast address 255.255.255.255 to do this. the problem is that the rogue compuer doesn't have a route back to the originating computer, so it'll drop the packet. Perhaps I've misunderstood something, but the diagram below shows my understanding of what would happen.

+1  A: 

What you want is broadcast, here's an article about it:

http://www.codeproject.com/KB/cs/BroadCasting.aspx

Matias Valdenegro
What about the situation where one computer is 192.168.1.30 and the other is 10.0.0.47 (with no default gateway). The second computer has no route back to the first computer, so is it even possible for it to respond?
Stephen Jennings
+2  A: 

You can look into various discovery protocols, in particular SNMP discovery. You can also do something simple like listen for UDP broadcasts and each computer and then respond. Bear in mind that all these solution can introduce security holes, and your customers might not appreciate that.

GregS
Since SNMP runs over UDP, and UDP runs on top of IP, won't the computers need to already be on the same subnet for this to work? Can SNMP detect all computers regardless of what subnet they're on?
Stephen Jennings
In general, broadcast packets are not forwarded by routers. So every computer needs to be able to receive a broadcast packet from 192.168.1.30. If this is not possible, then you can use scanning as suggested by drachestern. You can also attempt to build ad-hoc mesh networks by scanning from every machine. This is quite complicated and I would hesitate to recommend it, but you might be able to reuse open source p2p software like gnutella etc.
GregS
I'm not trying to go through routers, but 10.0.0.x cannot reply to a broadcast packet sent to 192.168.1.x, since it has no route back to the source. They're not on the same logical subnet, even if they're plugged into the same switch.
Stephen Jennings
Well, why would the 10.0.0.x computer be configured so as to be unable to communicate with any machine? Anyway, you could have the 10.0.0.x machine also send its response on the UDP broadcast address, but broadcasting is not a very nice way of doing unicast communications. It can be done this way if it must, I suppose.
GregS
You're right. I don't know why I didn't think to have the rogue computer broadcast its response back. Inefficient and noisy, but gets the job done and it's a rare occurance anyway.
Stephen Jennings
I finally got around to building a proof-of-concept of this yesterday and it works beautifully. Thanks.
Stephen Jennings
A: 

You can use the multicast/broadcast addresses to communicate with all the computer of your network.

You can refer to this topic for how to use that technology for .NET application :

http://stackoverflow.com/questions/515572/multicast-support-in-net

The basic concept behind that is that your clients are going to be listening on that multicast address and when they receive information (PING) they can send it back (PONG).

HoLyVieR
A: 

It has been my experience that usually there are three approaches.

Have a predefined number of IP addresses that a computer will always try and contact when it comes online (say, 192.168.x.250, 192.168.x.230, etc) and let that computer be the proxy by which you can connect to every other computer on the network. Said software would be running as a service and every 5? minutes would reconnect to the server to confirm it's still online.

Alternately, just scan every IP address iteratively. Yes this takes time, no it's not "taxing", as we're talking hardware and software. You will generate network traffic this way, of course. And quite a bit of it. But since you know what the possible IP ranges are, you can scan them.

The third being broadcast, but that's a little different.

These are both brute force techniques. I would start there and refine as appropriate. Occam's Razor and all that mess. (Yes, I realize it is accurately "pluralities ought not be posited without necessity" but it sounds cooler to say Occam's Razor ~ Shall we try Einstein: "Make everything as simple as it should be, but no simpler"?)

drachenstern
A: 

Assuming you have a testbed that resembles your picture

1 - On the 192.168.1.30 PC get a dos prompt
2 - Type  arp 10.0.0.47 <enter>
3 - Type  arp -a <enter>

Does the 10.0.0.47 have an entry?

dbasnett