2

I'm searching for a method to determine if a pc (whose IP address I know) is or not in LAN connection with mine. I've tried asking subnet mask of both and comparing each bit of IP addresses, but I'm asking if there's a better and more direct way to do that. Sorry for my bad english :S

  • 1
    What could be more direct than looking if both IPs inside the same subnet? – Victor Sorokin Jul 8 '11 at 14:15
  • 1
    Oh, you want to know if both computers (yours and the other) are in the same subnet, in direct connection, without going through a router? – woliveirajr Jul 8 '11 at 14:16
  • Maybe my networking basics are a bit rusty, but what would being in the same subnet or not have to do with having a LAN connection? Anyway if you want to check if they're in the same subnet then yes checking subnet masks is obviously the way to go. – Voo Jul 8 '11 at 14:18
  • Not all IPs in your LAN will have the same subnet mask, at least when we talk about large enterprises and complex routing infrastructure. I can think of only one solution: maintain a whitelist (e.g. a file) that contains the IP address ranges you're interested in. – home Jul 8 '11 at 14:24
  • I wonder if we might be missing the bigger picture here. Why is it that you want to know whether there's a direct LAN connection? Perhaps there's an alternative check/piece of information that will serve the same purpose. – Andrzej Doyle Jul 8 '11 at 14:39
1

It's hard to get a good answer if you're not defining the problem clearly: how do YOU tell if they're in the same LAN? Same switch, same subnet, same physical building?

Checking subnet should do the trick for most situations.

Other approach (if the two PCs have been "talking" to each other) is to check out ARP table to see if the IP is there: arp -a from command prompt. This means you have Layer 2 connectivity with it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.