For how to judge whether the IP address is in the same network segment, first of all, we need to know the concept of subnet mask. The detailed process is as follows:
1. Subnet mask is a 32-bit address. The function of subnet mask is to mask part of IP address to distinguish network ID and host ID, and to indicate whether the IP address is on LAN or remote network. General IP address settings are as follows:
2. But how to get network ID and host ID?The solution of network identificationAs follows:“And” the binary of the subnet mask and the binary of the IP address。 The details are as follows:
3, host identification：Negate the binary value of the subnet mask, and the IP address,The details are as follows:
4. To determine whether two IP addresses are in the same network segment, you need to compare the network identification (network address),If the network ID is the same, it is in the same subnet; otherwise, it is not in the same subnet。 As follows:
How to set two IP addresses on a computer?
How to add a cross network IP address for a network card?
How to set the hosts file? Binding IP address to domain name