Hello everyone!
Now let's learn about IP addresses and masks.
Classification of IP Address

The network part of an IP address is called a network address. A network address uniquely identifies a network segment or an aggregation of several network segments. Network devices in the same network segment have the same network address. The host part of an IP address is called a host address, which uniquely identifies a network device on the same network segment. For example, the class A IP address is 10.110.192.111, the network address is 10, and the host address is 110.192.111.
How to distinguish the network address and host address of an IP address? Initially, the designers of interconnection networks define address classes based on the network scale. IP addresses are classified into five classes: A, B, C, D, and E.
The network address of a class A IP address is the first octet, and the first byte starts with 0. Therefore, the number of valid bits of a class A network address is 7 (8 – 1), and the first byte of the class A network address ranges from 1 to 126 (127 is reserved). For example, 10.1.1.1 and 126.2.4.78 are class A addresses. The length of the host address of a class A address is the last three bytes (24 bits). Class A IP addresses range from 1.0.0.0 to 126.255.255.255. Each class A network has 224 class A IP addresses.
The network address of a class B IP address is the first two octets, and the first byte starts with 10. Therefore, the number of valid bits of a class B network address is 14 (16 – 2), and the first byte of the class B network address ranges from 128 to 191. For example, 128.1.1.1 and 168.2.4.78 are class B addresses. The length of the host address of a class B address is the last two bytes (16 bits). Class B IP addresses range from 128.0.0.0 to 191.255.255.255. Each class B network has 216 class B IP addresses.
The network address of a class C IP address is the first three octets, and the first byte starts with 110. Therefore, the number of valid bits of a class C IP address is 21 (24 – 3), and the first byte of class C IP address ranges from 192 to 223. For example, 192.1.1.1 and 120.2.4.78 are class C addresses. The host address in a Class C address is the last octet (8 bits). Class C IP addresses range from 192.0.0.0 to 223.255.255.255. Each class C network has 28 = 256 class C IP addresses.
The first octet of a class D address starts with 1110. Therefore, the first byte of a class D address ranges from 224 to 239. Class D addresses are usually used as multicast addresses.
The first byte of a class E address ranges from 240 to 255 and is reserved for scientific research.
Special IP Address

An IP address is used to uniquely identify a network device, but not every IP address is available. Some special IP addresses are used for various purposes and cannot be used to identify network devices.
An IP address whose host part is all 0s is called a network address. A network address identifies a network segment. For example, class A address 1.0.0.0, private address 10.0.0.0, and 192.168.1.0.
An IP address whose host part is all 1s is called a network segment broadcast address. A broadcast address identifies all hosts on a network. For example, a router can forward broadcast packets on network segments such as 10.0.0.0 or 192.168.1.0, for example, 10.255.255.255 and 192.168.1.255. A broadcast address is used to send data packets to all nodes on the local network segment.
An IP address whose network segment is 127, such as 127.0.0.1, is usually used for loop tests.
The IP address 0.0.0.0 with all 0s represents all hosts. Huawei VRP series routers use the IP address 0.0.0.0 to specify the default route.
The all-1 IP address 255.255.255.255 is also a broadcast address. 255.255.255.255 represents all hosts and is used to send data packets to all nodes on the network. Such broadcast packets cannot be forwarded by routers.
For example, a class B network segment 172.16.0.0 has 16 host bits, so it has 216 IP addresses. After 172.16.0.0 is removed, a broadcast address 172.16.255.255 cannot be used to identify a host. Therefore, there are 216-2 available addresses in total.
Class C network segment 192.168.1.0 has 8 host bits and a total of 28 = 256 IP addresses. After the network address, 192.168.1.0, and broadcast address 192.168.1.255 are excluded, there are 254 available host addresses.
The number of available host addresses on each network segment can be calculated using the following formula: If the number of bits in the host part of the network segment is n, the number of available host addresses is 2n-2.
Network-layer devices, such as routers, use network addresses to represent hosts on the local network segment. This greatly reduces the number of routing entries on routers.
Private IP Address
During IP address planning, private IP addresses are usually used on the internal network of a company.
Private IP addresses are reserved by the InterNIC and allocated by the intranets of enterprises. A user cannot directly access the Internet using a private IP address. The reason is simple. The private IP address cannot be used on the public network. There is no route for the private IP address on the public network. Therefore, the address conflict problem occurs. When users access the Internet, the network address translation (NAT) technology is used to translate private IP addresses into public IP addresses that can be identified by the Internet.
The following network segments are reserved as private IP addresses for the InterNIC:
Class A 10.0.0.0~10.255.255.255;
Class B 172.16.0.0~ 172.31.255.255;
Class C 192.168.0.0~192.168.255.255
Using private IP addresses not only reduces the investment in purchasing public IP addresses but also saves IP address resources.
Subnet Mask Introduction
The mask format is the same as the IP address format.
The network part and subnet part of the mask are both 1, and the host part is all 0.
The mask and IP address are expressed in the same way. In the mask, 1 indicates the network bit, and 0 indicates the host. A 255 indicates eight ones.
By default, the subnet mask of the class A network is 255.0.0.0, that of the class B network is 255.255.0.0, and that of the class C network is 255.255.255.0.
For example, the subnet mask of the class B network is 255.555.0.0
Subnet Mask Representation
According to the TCP/IP protocol stack, a 32-bit subnet mask is used to indicate the length of the subnet number field.
The subnet mask consists of a series of 1 and 0.
Value 1 corresponds to the network number and subnet number fields.
Value 0 corresponds to the host number field.
1 and 0 cannot be used at the same time.

With a good command of binary-to-decimal conversions, the correspondence between IP addresses and subnet masks in binary and decimal systems is easy to understand. The number of bits in the subnet mask is 28 (8 + 8 + 8 + 4 = 28), indicating that the number of consecutive 1s in the subnet mask is 28 (1, indicating that there are 28 network bits).
Another representation of the subnet mask is /28=255.255.255.240, which is called backslash notation.
IP addresses are hierarchical;
The IP address is different from the phone number, which cannot reflect the geographical location of the host;
A host that belongs to multiple networks and has multiple IP addresses (such as a router). The networks and subnets of these IP addresses are different.
System Conversion of IP Address

Each IP address is a 32-bit value written in four 8-bit bytes. This means that there are four groups, each of which contains eight binary bits, as shown in the figure above.
Thanks for reading!
