0

If you have multiple members in a household using each their own PCs, some connected wirelessly, some via LAN cable - How can you check if all those PCs are all in the same subnet or broadcast domain?

Please advise step by step how to check it on both systems Linux and Windows? Any straight forward command line available?

To clarify: By LAN I mean a PC connected via wired LAN Cable to the Router. By WIFI I mean a wireless connected PC.

Thanks

2 Answers2

2

You need to know subnet mask and IPv4 adress of each PC.
Open a command/terminal prompt. Type:
ipconfig for Windows
ifconfig for Linux.
Press ENTER.

Look at the subnet mask. Does it match?
NO: You know right away computers are not on the same network.
YES: Proceed below to determine whether or not computers are on the same subnet.

Compare IP addresses to determine if devices are on the same subnet.

We will be using most common subnet mask of 255.255.255.0 as example. It tells us the size of the network block:

  • In each of the four sections, if the value is 255, we will substitute that with a 0.
  • If there is any other number in the section, we then subtract that number from 256.
  • In the example above, we would get 0.0.0.256 (256 - 0 = 256). This is a block of 256 numbers.

If the subnet were 255.255.252.0, we substitute and get 0.0.4.256. This is a block of 1024 addresses (4 x 256 = 1024).

When comparing two IP address/subnet combinations, the addresses must match for any section where the subnet value is 255. For a subnet of 255.255.255.0, we expect to see the first three sections of the IP address match (reading left to right) if they are in the same subnet.

The key is to match up the subnet and the IP address. Let’s look at four examples: enter image description here

1

There is a way then @BaldEagle answer if you don't want to do math or worry about netmasks. This way is more reliable as it can work even if you have 2 isolated networks both with same the ip range ( eg an office with 2 internet connections, 2 routers both set up with the default 192.168.1.1/24 and doing NAT).

Establish the IP address of system 1. Have the a system 1 ping another system 2 and while (or shortly after) this ping is in process on system 2 in a terminal or command window type "arp -an" If the IP address on system 1 appears in the list of entries its on the same subnet (and this will be true even if ping fails to respond).

I have assumed here that devices only have 1 route to see each other. (Ie things might break down in cases where a device has an Ethernet and WiFi connection - in this case you need to know the iIP address of the interface sendingvthe ping - typically the LAN one).

The idea here is that (for systems calculated by system 1 as being in the broadcast domain - which is done at a technical level as per BaldEagle answer) will send a broadcast packet "who has IP address X" - and the appropriate machine will respond "me, here us my MAC address", and IP and the systems can then communicate directly. The ARP command shows the table of remembered addresses.

davidgo
  • 73,366