
In today’s digitalized world, network connectivity is ubiquitous, and IP addresses and subnet masks are key elements in ensuring its smoothness. Understanding the relationship between IP address and subnet mask can help us better understand the construction and maintenance of the network, providing a guarantee for the smooth transmission of information.
Imagine that an IP address is like the address of a house that uniquely identifies each device connected to the Internet. A subnet mask, on the other hand, is like a postal system that helps us understand which neighborhood or block the house is located in. Subnet masks are often used in conjunction with IP addresses, such as 255.255.255.0, and in this way, we can determine which devices are on the same LAN.
The IP address is the device’s identity, and the subnet mask helps us properly delineate and manage those identities.
What is IP Address
IP address meaning
An IP address (Internet Protocol Address), also known as an Internet Protocol (IP) address, is a format for uniformly addressing hosts on the Internet. It assigns a logical address to every network and every host on the Internet.
IP addresses are commonly divided into two categories: IPv4 and IPv6. IPv4 is currently the most widely used, but it is almost exhausted. Upgrading to IPv6 will inevitably follow. Unless otherwise specified, we generally refer to IPv4 when discussing IP addresses.
IP addresses correspond to the OSI reference model’s third layer. The router’s network layer works according to the destination IP and source IP to determine whether the packet belongs to the same network segment. If it belongs to a different network segment, then forward the packet.
IP address format and representation
An IP address (IPv4) consists of a 32-bit binary number divided into 4 segments (4 bytes), each segment being an 8-bit binary number (1 byte). Each segment is an 8-bit binary separated by the English punctuation mark “.” Separated by the punctuation mark “.
Because binary numbers are too long, each 8-bit binary number is converted into a decimal number, size 0 to 255, to facilitate memory and recognition. This representation of IP addresses is called “dotted decimal representation.”IP address is expressed as: xxx.xxx.xxx.xx. For example, 210.21.196.6 is an IP address.
IP address classification
IP addresses are categorized into classes A, B, C, D, and E. The last two are unique, non-user-related classes. These are particular addresses that have nothing to do with the user. Class A, B, and C IP addresses are described below.
Note: An address with a byte of 0 (0.0.0.0) is a host address. Therefore, an IP address (255.255.255.255) with a 1 in each byte of the IP address is a broadcast address and should be excluded.

Class A addresses:
The first bit of class A must be 0.
Address range: 1.0.0.0-126.255.255.255
Default Subnet Mask: 255.0.0.0 or 0xFF000000 (hex) Usually used for large networks.
Class B address:
The first 2 bits of the Class B address are fixed at 10.
Address range: 128.0.0.1-191.255.255.254
Default Subnet Mask: 255.255.0.0 or 0xFFFF0000 (hex) Usually used for medium-sized networks.
Class C address:
The first 3 bits are fixed to 110.
Address range: 192.0.0.0-223.255.255.255
Subnet mask: 255.255.255.0 or 0xFFFFFF00 (hexadecimal) Usually used for small networks
What is a subnet mask?
A subnet mask, also known as a network mask, address mask, or subnet mask, indicates which bits of an IP address identify the subnet in which a host is located and which bits identify the host’s bit mask. A subnet mask is a 32-bit binary number with all bits of the network address set to 1 and all bits of the host address set to 0.
Actually, A subnet mask cannot stand alone. It must be used in conjunction with an IP address. A subnet mask serves only one purpose: to divide an IP address into two parts: the network and host addresses.
A subnet mask is a virtual lP technology that solves the problem of lP address allocation in the context of the shortage of IPv4 address resources. The subnet mask will be divided into several subnets of A, B, and C addresses, thus significantly improving the efficiency of IP address allocation and effectively solving the IP address resource constraints.
On the other hand, to better manage the network in the enterprise intranet, network administrators also use the role of a subnet mask to artificially divide a larger enterprise internal network into more small-scale subnets and then utilize the routing function of Layer 3 switches to realize the interconnection of the subnets. Thus, it effectively solves network broadcasting storms, viruses, and other network management problems.
Connection between IP address and subnet mask
Subnet masks can split an existing IP address into a network and a host address, allowing us to determine which subnet the host is located on.
Let’s assume that 255.255.255.128 is the subnet mask for IP 192.168.254.130 in this example:
11000000 01010001 11111110 10000010 (IP address 192.168.254.130)
111111111 111111111 11111111 10000000 (subnet mask 255.255.255.128)
AND (& &) both, the resulting address is the network address
11000000 01010001 1111110 1000000 (network address 192.168.254.128)
Reverse the subnet mask and then perform an AND on the IP address (& &) to get the host address:
11000000 01010001 11111110 10000010 (IP address 192.168.254.130)
00000000 00000000 0000001 011111111 (reverse subnet mask)
Calculation results:
0000000 0000000 0000000 00000010 (host address 0.0.0.2)
In this case, the packet arrives at subnet 192.168.254.128 with destination address 192.168.254.130.
Conclusion
With a subnet mask, the division of network bits and host bits of an IP address becomes more flexible, improving its utilization and reducing waste in the case of limited IP resources.
Read more
- Ethernet Switch vs Hub: What’s the Difference?
- How to make ethernet cable?
- IPsec (Internet Protocol Security
Reference