Computer ScienceNetworking & SystemsMedium

Subnet Mask

Also known as:Network MaskCIDR PrefixNetmask

A subnet mask is a 32-bit number used in conjunction with an IP address to divide a network into smaller sub-networks (subnets) by identifying which bits of the IP address represent the network portion and which represent the host portion. Written in dotted-decimal notation (e.g., 255.255.255.0) or CIDR notation (e.g., /24), it enables routers and devices to determine whether a destination address is on the local network or must be forwarded to another network. Subnetting improves network performance, security, and efficient use of IP address space.

Key Formula

Hosts per subnet = 2^h - 2

LaTeX: \text{Hosts per subnet} = 2^{h} - 2

SymbolMeaningUnit
hNumber of host bits (bits set to 0 in the mask)bits
2Binary basenone
-2Subtract network address and broadcast addressnone

Worked Example

Problem

A network uses IP address 192.168.1.0 with subnet mask 255.255.255.0 (/24). How many usable host addresses are available?

Solution

Step 1: Identify host bits. Subnet mask /24 means 24 bits are network bits, leaving 32 - 24 = 8 host bits. Step 2: Calculate total addresses. 2^8 = 256 total addresses. Step 3: Subtract unusable addresses. 256 - 2 = 254 (subtract network address 192.168.1.0 and broadcast address 192.168.1.255). Step 4: Usable range = 192.168.1.1 to 192.168.1.254.

Answer

254 usable host addresses (192.168.1.1 – 192.168.1.254)

Common Subnet Masks and Their Properties

CIDRSubnet MaskHost BitsUsable HostsExample Use
/8255.0.0.02416,777,214Class A large network
/16255.255.0.01665,534Class B medium network
/24255.255.255.08254Small office LAN
/28255.255.255.240414Small VLAN segment
/30255.255.255.25222Point-to-point link

Interactive Tools

Subnet Calculator

Calculate subnets, host ranges, and broadcast addresses interactively

Open Tool

WolframAlpha

Compute subnet mask properties and CIDR notation conversions

Open Tool

Brilliant.org

Guided problems on subnetting and CIDR notation

Open Tool
Subnet mask dividing a network into sub-networks diagram

Wikimedia Commons, CC BY-SA

Related Terms

Computer Science

IP Address

An IP (Internet Protocol) address is a unique numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. IPv4 addresses are 32-bit numbers typically written in dotted-decimal notation (e.g., 192.168.1.1), providing approximately 4.3 billion unique addresses, while IPv6 addresses are 128-bit numbers written in hexadecimal (e.g., 2001:0db8:85a3::8a2e:0370:7334) to accommodate the growing number of internet-connected devices. IP addresses serve two principal functions: host or network interface identification and location addressing.

Computer Science

Network Routing

Network routing is the process by which routers select the optimal path for data packets to travel from a source to a destination across one or more networks. Routers maintain routing tables — databases of known network paths — and use routing protocols such as OSPF, BGP, and RIP to dynamically discover and share path information. Routing decisions are based on metrics including hop count, bandwidth, latency, and cost, ensuring efficient and reliable delivery of data across complex internetworks.

Computer Science

TCP/IP Protocol

TCP/IP (Transmission Control Protocol/Internet Protocol) is the foundational suite of communication protocols used to interconnect network devices on the internet and most private networks. TCP handles reliable, ordered delivery of data by breaking messages into packets, acknowledging receipt, and retransmitting lost segments, while IP handles addressing and routing each packet to its destination. Together they form the backbone of modern digital communication, enabling everything from web browsing to email.

The term "subnet" is a portmanteau of "sub-network," introduced with CIDR (Classless Inter-Domain Routing) in RFC 1519 (1993). "Mask" refers to the bitwise AND operation applied to an IP address to extract the network portion, analogous to a physical mask that covers part of a face. The concept was developed to address IPv4 address exhaustion.

subnetnetworkingip-addresscidrroutingsubnetting