The relationship between subnet mask and IP address: 1. Subnet mask is used to determine whether the IP addresses of two computers belong to the same subnet. That is, subnet mask and IP address can Determine the relationship between unique addresses; 2. Perform binary conversion on the subnet mask and IP address and perform the AND algorithm, which is the only external address; 3. The subnet mask can be used to distinguish the network address and the host address.
The operating environment of this tutorial: Windows 10 system, DELL G3 computer.
IP address
IP is 32 bits Binary data, usually expressed in dotted decimal notation. An IP address is a logical address that is used to identify each host in the network. IP is unique, that is, the IP of each machine is unique in the world.
To achieve network communication between computers, they must have a legal IP address. IP address = network address, host address, (also known as: host number and network number) The structure of the IP address allows us to conveniently address on the Internet. The IP address is usually represented more intuitively by four decimal numbers separated by dots. Each number ranges from 0 to 255. For example, the IP address of a certain host is: 128.20.4.1 In a local area network, an IP address is also required. , Generally, the IP address of the internal network starts with 192.168, so it is easy to distinguish the IP addresses of the public network and the internal network.
Subnet mask
The subnet mask is used to determine whether the IP addresses of any two computers belong to the same subnet. . The simplest understanding is that after the AND operation of the respective IP addresses and subnet masks of the two computers, the results are the same, which means that the two computers are on the same subnet and can communicate directly.
Relationship
The two are combined to determine the relationship of the unique address.
Convert the two to binary and perform the AND algorithm, which is your unique external address. For example, in a LAN, after performing the AND algorithm on the IP and mask of each host, the address all the same. This is your only external address.
Subnet address includes network address, host address and broadcast address.
The subnet mask is used to distinguish the network address and the host address.
For example, the subnet is 192.168.1.0, and the subnet mask is 255.255.255.0. Network address: 192.168.1.0, this address is used in the router’s routing table.
Host address: 192.168.1.1 to 192.168.1.254, used to identify different hosts; broadcast address: 192.168.1.255, used to send messages to all host devices in the network segment.
Mask: 255 is expressed in binary as 8 1s, 11111111, 3 255 is expressed in binary as 24 1s, corresponding to the network address part of the IP address: 192.168.1, this part is for all on this network The hosts in the segment are all the same, and the last 0 of the mask corresponds to the 8 binary 0s. This part is different for different hosts, and corresponds to 1~254 in this network segment.
IP address and mask use binary AND operation to obtain the network part and host part of the IP address.
For more related knowledge, please visit the FAQ column!
The above is the detailed content of What is the relationship between subnet mask and ip address?. For more information, please follow other related articles on the PHP Chinese website!