Subnets and network masks

Subnet is a portion of a computer network that is separated from the main network using a subnet mask.

Creating subnets allows for better organization of the network, improved performance, and increased security. Each subnet can have its own IP addresses and network devices, and communication between them is done through routing.

In this way, large networks can be divided into smaller, more organized parts, making them easier to manage.

The subnet mask is used to determine which bits of the IP address belong to the subnet identifier and which bits belong to the host identifier.

CIDR (Classless Inter-Domain Routing) is a method of dividing IP addresses in computer networks. It is a way to reduce the amount of information required to determine subnets and host addresses in a given network area.

CIDR replaced the older system of dividing IP addresses into classes (Class A, B, and C) and enabled more flexible and efficient use of available IP addresses. In CIDR, the IP address is written as the network address and the network prefix length, which specifies how many bits in the IP address should be interpreted as the network address.

For example, in CIDR, the address 192.168.1.1 / 24 means that the first 24 bits of the IP address represent the network address, and the remaining bits represent the host address in that network. The network prefix length can be any number and can be used to define subnets within a larger IP network.


Table of typical subnets for IPv4:

CIDR prefix size Network mask Number of usable hosts in subnet
/1 128.0.0.0 2147483646
/2 192.0.0.0 1073741822
/3 224.0.0.0 536870910
/4 240.0.0.0 268435454
/5 248.0.0.0 134217726
/6 252.0.0.0 67108862
/7 254.0.0.0 33554430
Class A
/8 255.0.0.0 16777214
/9 255.128.0.0 8388606
/10 255.192.0.0 4194302
/11 255.224.0.0 2097150
/12 255.240.0.0 1048574
/13 255.248.0.0 524286
/14 255.252.0.0 262142
/15 255.254.0.0 131070
Class B
/16 255.255.0.0 65534
/17 255.255.128.0 32766
/18 255.255.192.0 16382
/19 255.255.224.0 8190
/20 255.255.240.0 4094
/21 255.255.248.0 2046
/22 255.255.252.0 1022
/23 255.255.254.0 510
Class C
/24 255.255.255.0 254
/25 255.255.255.128 126
/26 255.255.255.192 62
/27 255.255.255.224 30
/28 255.255.255.240 14
/29 255.255.255.248 6
/30 255.255.255.252 2
/31 255.255.255.254 0
/32 255.255.255.255 0