The IP address is divided into IPv4 (32-bit) and IPv6 (128-bit ). IPv6 is proposed to cope with the problem of insufficient IP addresses in the future, but IPv4 is still the mainstream.
An IP address is divided into four segments, each of which has eight bits. The segments and segments are separated. For easy representation, IP addresses convert binary without segments to decimal.
The IP address is divided into two parts: the domain number (net_id) and the host number (host_id). IP addresses can be divided into five categories based on the number of occupied domain numbers and host numbers:
A: 0xxxxxxx. XXXXXXXX
B: 10xxxxxx. XXXXXXXX
C: 110xxxxx. XXXXXXXX
D: 1110xxxx. XXXXXXXX
E: 1111xxxx. XXXXXXXX
There is a private IP in A, B, and C respectively:
A: 10.0.0.0 ~~~~~~~~ 10.20.255.255
B: 172.16.0.0 ~~~~~~~~~ 172.31.255.255
C: 192.168.0.0 ~~~~~~~~ 192.168.255.255
Classes A, B, and C can be further divided into multiple subnets. Each subnet has a subnet mask.
The subnet mask has 32 bits. If the subnet has 24 bits and the host number has 8 bits, the subnet mask consists of 24 1 s and 8 0 s: 11111111.111111.11111111.00000000
Therefore, the number 1 in a subnet mask represents the number of domain numbers in the subnet, And the number 0 represents the number of host numbers in the subnet.