| Lesson 8 | Netmask Structure and Usage |
| Objective | What is the Structure and use of a netmask? |
The netmask, also known as a subnet mask, is one of the fundamental elements of IP networking. It defines how an IP address is divided into two parts: the network identifier and the host identifier. Understanding the netmask is essential for configuring networks, designing subnets, and managing routing in both IPv4 and IPv6 environments.
In early TCP/IP implementations, networks followed a classful addressing scheme:
| Class | Default Netmask |
|---|---|
| Class A | 255.0.0.0 |
| Class B | 255.255.0.0 |
| Class C | 255.255.255.0 |
Each class reserved a fixed number of bits for the network portion. However, this approach led to address waste and limited scalability. Modern networks use CIDR (Classless Inter-Domain Routing), which replaces rigid class boundaries with prefix lengths (e.g., /24, /20). CIDR allows variable subnet sizes and more efficient use of IP space.
A netmask is a 32-bit binary number that separates the network and host portions of an IP address. The bits set to 1 mark the network portion, and those set to 0 mark the host portion. For example:
IP Address: 192.168.1.25
Netmask: 255.255.255.0
Binary form: 11111111.11111111.11111111.00000000
Network part: 192.168.1
Host part: .25
The count of 1 bits in the mask determines the prefix length. Thus, 255.255.255.0 corresponds to /24 since 24 bits are reserved for the network portion.
192.168.10.14/24 recognizes that 192.168.10.0 – 192.168.10.255 are local addresses.192.168.1.0/24 into four subnets uses /26 masks:
192.168.1.0/26 → hosts 1–62
192.168.1.64/26 → hosts 65–126
192.168.1.128/26 → hosts 129–190
192.168.1.192/26 → hosts 193–254
Subnetting improves performance and security by isolating traffic./24 networks (192.168.0.0–192.168.3.255) into one 192.168.0.0/22 aggregate simplifies routing tables and reduces overhead.| Prefix | Netmask | Usable Hosts | Typical Use |
|---|---|---|---|
| /30 | 255.255.255.252 | 2 | Point-to-point links |
| /29 | 255.255.255.248 | 6 | Small subnets (firewall segments) |
| /24 | 255.255.255.0 | 254 | Standard LAN |
| /16 | 255.255.0.0 | 65,534 | Enterprise campus networks |
In IPv6, the concept of a netmask still exists but is expressed exclusively with prefix lengths. IPv6 addresses typically use a /64 prefix for LANs, reserving 64 bits for network routing and 64 bits for interface identifiers (derived from MAC addresses or randomly generated for privacy).
Example:
IPv6 Address: 2001:db8:abcd:12::1/64
Network ID: 2001:db8:abcd:12::
IPv6 eliminates broadcast traffic entirely, replacing it with multicast mechanisms for efficiency and scalability.
# Display all network interfaces and prefixes
ip addr show
# View routing tables with netmask or CIDR notation
ip route show
# Add an address with a specific netmask
sudo ip addr add 10.42.1.10/24 dev eth0
# Add a static route
sudo ip route add 10.42.0.0/16 via 10.42.1.1
A netmask identifies the boundary between the network and host portions of an IP address. Modern networks use CIDR prefixes instead of rigid class-based masks, enabling flexible subnetting and efficient routing. Whether you’re designing a small LAN or configuring routes for a hybrid cloud, understanding how netmasks define network scope is essential for stable, scalable connectivity.