# How to Determine if 2 IPs are on the Same Subnet

By Serm Murmson

A subnet is a partition of a network on which multiple devices or connections may exist, set apart from the network host. If you have multiple computers on a network, you may wish to determine whether they are part of the same subnet. This is useful for understanding the flow of data within a network. To do this, you will need to do some binary conversion and calculation.

Obtain your IP address and subnet mask number. In Windows, you can do this by accessing the Command Prompt utility and running "ipconfig" or by viewing the details of your connection through the Network and Sharing Center. In Mac OS X, you can do this by accessing the System Preferences menu and selecting the "Network" option.

Convert both numbers to binary. Binary is a numeric system in which only 1 and 0 are used. The number 2 is represented as "10", 4 is "100", and so on. For example, 110 corresponds to one 4, one 2, and no 1, so the actual number represented by 110 is 6. The first eight positions of binary correspond to 128, 64, 32, 16, 8, 4, 2 and 1. You will need to convert each section of the number separated by a period. An IP of 192.168.1.100 converts in the following way:

192 converts to 11000000 (128 + 64)

168 converts to 10101000 (128 + 32 + 8)

1 converts to 00000001

100 converts to 01100100 (64 + 32 + 4)

Likewise, a subnet mask of 255.255.255.0 converts to:

11111111.11111111.11111111.00000000

Compare the two binary numbers by columns. Wherever both numbers are 1, write down a 1. This is the binary operation "AND." For example:

11000000.10101000.00000001.01100100

11111111.11111111.11111111.00000000

The result would be 11000000.10101000.00000001.00000000

Obtain the second IP and subnet mask numbers.

Convert these to binary.

Perform the "AND" comparison with the second pair of numbers.

Compare the two results of the AND operations. If they are identical, the two IPs are on the same subnet. If they are not identical, they are not on the same subnet. For example, if the second AND result was also 11000000.10101000.00000001.00000000, the two IPs would be on the same subnet.

References

Writer Bio

Serm Murmson is a writer, thinker, musician and many other things. He has a bachelor's degree in anthropology from the University of Chicago. His concerns include such things as categories, language, descriptions, representation, criticism and labor. He has been writing professionally since 2008.