The subnet mask identifies your network ID. If you want to know what subnet a host is on, you’d refer to the subnet mask.
The subnet mask masks (or blocks) the network portion of an IP address. In binary, a 1 in the subnet mask identifies the network ID, while a 0 identifies the host ID.
A typical subnet mask is 255.255.255.0. In binary this is 11111111.11111111.11111111.00000000. Any part that is 255 (equivalent to 11111111 in binary) is the network ID. Any part that is a 0 is the host ID.
Example – IP: 192.168.4.33 with subnet mask: 255.255.255.0 means network ID: 192.168.4 & host ID: 33
Every computer on a single LAN has the same network ID but has a unique host ID
Subnet mask is used by the local device to determine what subnet it’s on. It’s usually something you configure on the local workstation rather than being a value that’s transmitted across the network.
CIDR
CIDR stands for Classless Inter-Domain Routing. There are default subnet masks of 255.0.0.0, 255.255.0.0, 255.255.255.0. In binary these default subnet masks have 1’s filling up an entire octet. However, CIDR allows a network administrator to have more flexible allocation of IP addresses. The 1’s in a subnet mask do not need to fill an entire octet. For example, you have a subnet mask of 11111111.11111111.11110000.00000000. This would be a subnet mask of 255.255.240.0. There is also CIDR notation which counts the number of 1’s. So in CIDR notation, the subnet mask would be represented as “\20” because there are 20 1’s in the binary subnet mask. This leaves 12 digits for the host ID so 212 – 2 = 4094 unique addresses.
IPv6 Subnet Mask:
The last 64 bits of an IPv6 IP address are generated randomly or using the MAC, leaving a maximum of 64 bits for the network ID, so no subnet is ever longer than /64
Majority of IPv6 subnets are between /48 and /64