Subnet mask, also known as network mask, address mask and subnet mask, is used to indicate which bits of an IP address identify the subnet of the host and which bits identify the bit mask of the host. The subnet mask cannot exist alone; it must be used in combination with an IP address.
Subnet mask is also called network mask, address mask and subnet mask. It is used to indicate which bits of an IP address identify the subnet of the host and which bits identify the bit mask of the host. The subnet mask cannot exist alone; it must be used in combination with an IP address. Subnet mask has only one function, which is to divide an IP address into two parts: network address and host address.
子网掩码是一个 32 位地址，用于屏蔽 IP 地址的一部分以区别网络标识和主机标识，并说明该 IP 地址是在局域网上，还是在广域网上。
The subnet mask is a 32-bit address, which is used to mask part of the IP address to distinguish the network ID from the host ID, and to indicate whether the IP address is on the LAN or WAN.
子网掩码是在 IPv4 地址资源紧缺的背景下为了解决 lP 地址分配而产生的虚拟 lP 技术，通过子网掩码将 A、B、C 三类地址划分为若干子网，从而显著提高了 IP 地址的分配效率，有效解决了 IP 地址资源紧张的局面。另一方面，在企业内网中为了更好地管理网络，网管人员也利用子网掩码的作用，人为地将一个较大的企业内部网络划分为更多个小规模的子网，再利用三层交换机的路由功能实现子网互联，从而有效解决了网络广播风暴和网络病毒等诸多网络管理方面的问题。
Subnet mask is a virtual LP technology to solve the problem of LP address allocation under the background of shortage of IPv4 address resources. Through the subnet mask, a, B, C three kinds of addresses are divided into several subnets, which significantly improves the efficiency of IP address allocation and effectively solves the shortage of IP address resources. On the other hand, in order to better manage the network in the enterprise intranet, the network management personnel also use the function of subnet mask to divide a larger enterprise internal network into more small-scale subnets, and then use the routing function of layer-3 switch to realize the interconnection of subnets, thus effectively solving many network management problems such as network broadcast storm and network virus.
在大多数的网络教科书中，一般都将子网掩码的作用描述为通过逻辑运算，将 IP 地址划分为网络标识(Net.ID)和主机标识(Host.ID)，只有网络标识相同的两台主机在无路由的情况下才能相互通信。
In most network textbooks, the function of subnet mask is generally described as dividing IP address into network identification through logical operation（ Net.ID ）And host ID（ Host.ID ）Only two hosts with the same network identity can communicate with each other without routing.
根据 RFC950 定义，子网掩码是一个 32 位的 2 进制数， 其对应网络地址的所有位都置为 1，对应于主机地址的所有位都置为 0。子网掩码告知路由器，地址的哪一部分是网络地址，哪一部分是主机地址，使路由器正确判断任意 IP 地址是否是本网段的，从而正确地进行路由。网络上，数据从一个地方传到另外一个地方，是依靠 IP 寻址。从逻辑上来讲，是两步的。第一步，从 IP 中找到所属的网络，好比是去找这个人是哪个小区的；第二步，再从 IP 中找到主机在这个网络中的位置，好比是在小区里面找到这个人。
According to the definition of rfc950, a subnet mask is a 32-bit binary number. All bits corresponding to the network address are set to 1 and all bits corresponding to the host address are set to 0. The subnet mask tells the router which part of the address is the network address and which part is the host address, so that the router can correctly determine whether any IP address belongs to the network segment, and then route correctly. On the network, data from one place to another depends on IP addressing. Logically speaking, it is a two-step process. The first step is to find the network from the IP, which is like finding out which cell the person belongs to; the second step is to find the host’s location in the network from the IP, which is like finding the person in the cell.
子网掩码的设定必须遵循一定的规则。与二进制 IP 地址相同，子网掩码由 1 和 0 组成，且 1 和 0 分别连续。子网掩码的长度也是 32 位，左边是网络位，用二进制数字“1”表示，1 的数目等于网络位的长度；右边是主机位，用二进制数字“0”表示，0 的数目等于主机位的长度。这样做的目的是为了让掩码与 IP 地址做按位与运算时用 0 遮住原主机数，而不改变原网络段数字，而且很容易通过 0 的位数确定子网的主机数（2 的主机位数次方-2，因为主机号全为 1 时表示该网络广播地址，全为 0 时表示该网络的网络号，这是两个特殊地址）。通过子网掩码，才能表明一台主机所在的子网与其他子网的关系，使网络正常工作。
The setting of subnet mask must follow certain rules. As with binary IP addresses, the subnet mask consists of 1 and 0, which are continuous. The length of the subnet mask is also 32 bits. On the left is the network bit, which is represented by the binary number “1”. The number of 1 is equal to the length of the network bit; the right is the host bit, which is represented by the binary number “0”, and the number of 0 is equal to the length of the host bit. The purpose of this method is to cover the number of original hosts with 0 when performing bitwise sum operation between mask and IP address, without changing the number of original network segments. Moreover, it is easy to determine the number of hosts in the subnet by the number of bits of 0 (the power of host bits of 2 is – 2, because when the host number is all 1, it means the broadcast address of the network; when all the host numbers are 0, it means the network number of the network, which are two special addresses). Through the subnet mask, the relationship between a host’s subnet and other subnets can be indicated, so that the network can work normally.
子网掩码是一个 32 位地址，是与 IP 地址结合使用的一种技术。它的主要作用有两个，一是用于屏蔽 IP 地址的一部分以区别网络标识和主机标识，并说明该 IP 地址是在局域网上，还是在远程网上。二是用于将一个大的 IP 网络划分为若干小的子网络。
The subnet mask is a 32-bit address, which is a technology combined with IP address. It has two main functions: one is to shield part of IP address to distinguish network identity from host identification, and to explain whether the IP address is on LAN or remote network. The other is to divide a large IP network into several small subnetworks.
使用子网是为了减少 IP 的浪费。因为随着互联网的发展，越来越多的网络产生，有的网络多则几百台，有的只有区区几台，这样就浪费了很多 IP 地址，所以要划分子网。使用子网可以提高网络应用的效率。
Subnet is used to reduce the waste of IP. Because with the development of the Internet, more and more networks are produced. Some networks are more than a few hundred, and some are only a few. In this way, a lot of IP addresses are wasted, so it is necessary to divide the subnet. Using subnet can improve the efficiency of network application.
通过计算机的子网掩码判断两台计算机是否属于同一网段的方法是，将计算机十进制的 IP 地址和子网掩码转换为二进制的形式，然后进行二进制“与”(AND)计算（全 1 则得 1，不全 1 则得 0），如果得出的结果是相同的，那么这两台计算机就属于同一网段。
The method of judging whether two computers belong to the same network segment through the subnet mask of the computer is to convert the decimal IP address and subnet mask of the computer into binary form, and then calculate the binary “and” (all 1 will get 1, and incomplete 1 will get 0). If the results are the same, then the two computers belong to the same network segment.