What is a Subnet Mask? - Complete Guide to Network Subnetting


What is a Subnet Mask?

A subnet mask is a 32-bit number that masks an IP address, and divides the IP address into network address and host address. The subnet mask is made by setting network bits to all "1"s and setting host bits to all "0"s. Within a given network, two host addresses are reserved for special purposes. The "0" address is assigned a network address and "255" is assigned to a broadcast address, and they cannot be assigned to hosts.

How Subnet Masks Work

The subnet mask determines which portion of an IP address is the network portion and which portion is the host portion. It works by using binary logic:

  • Network bits (1s): Identify the network portion of the IP address
  • Host bits (0s): Identify the host portion of the IP address

Common Subnet Masks

Subnet Mask Binary CIDR Network Bits Host Bits Max Hosts
255.0.0.0 11111111.00000000.00000000.00000000 /8 8 24 16,777,214
255.255.0.0 11111111.11111111.00000000.00000000 /16 16 16 65,534
255.255.255.0 11111111.11111111.11111111.00000000 /24 24 8 254

Example: How Subnet Masks Work

Let's use the IP address 192.168.1.100 with subnet mask 255.255.255.0:

IP Address: 192.168.1.100 Binary: 11000000.10101000.00000001.01100100

Subnet Mask: 255.255.255.0 Binary: 11111111.11111111.11111111.00000000

Network Portion: 192.168.1 (first 24 bits) Host Portion: 100 (last 8 bits)

CIDR Notation

Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and IP routing. It uses a slash notation to indicate the number of network bits:

  • /8 = 255.0.0.0 (Class A)
  • /16 = 255.255.0.0 (Class B)
  • /24 = 255.255.255.0 (Class C)
  • /25 = 255.255.255.128
  • /26 = 255.255.255.192
  • /27 = 255.255.255.224
  • /28 = 255.255.255.240
  • /29 = 255.255.255.248
  • /30 = 255.255.255.252

Subnetting Examples

Example 1: Class C Network

Network: 192.168.1.0/24 Subnet Mask: 255.255.255.0 Available Hosts: 192.168.1.1 to 192.168.1.254 (254 hosts) Network Address: 192.168.1.0 Broadcast Address: 192.168.1.255

Example 2: Subnetting a Class C Network

Original Network: 192.168.1.0/24 Subnet Mask: 255.255.255.192 (/26)

This creates 4 subnets:

  • 192.168.1.0/26 (192.168.1.1 - 192.168.1.62)
  • 192.168.1.64/26 (192.168.1.65 - 192.168.1.126)
  • 192.168.1.128/26 (192.168.1.129 - 192.168.1.190)
  • 192.168.1.192/26 (192.168.1.193 - 192.168.1.254)

Why Use Subnetting?

  1. Network Segmentation: Divide large networks into smaller, manageable segments
  2. Security: Isolate different parts of the network
  3. Performance: Reduce network traffic and improve performance
  4. Organization: Group related devices together
  5. IP Address Conservation: Use IP addresses more efficiently

Calculating Subnets

To calculate the number of subnets and hosts:

Number of Subnets = 2^(subnet bits) Number of Hosts per Subnet = 2^(host bits) - 2

The "-2" accounts for the network address and broadcast address.

Best Practices

  1. Plan your subnetting carefully before implementation
  2. Use consistent subnet sizes when possible
  3. Leave room for growth in your subnet design
  4. Document your subnet allocation
  5. Use private IP address ranges for internal networks
  6. Consider future expansion when designing subnets

Common Subnet Masks for Different Needs

Use Case Subnet Mask CIDR Max Hosts
Point-to-Point 255.255.255.252 /30 2
Small Network 255.255.255.248 /29 6
Medium Network 255.255.255.240 /28 14
Large Network 255.255.255.224 /27 30
Very Large Network 255.255.255.0 /24 254

IP FLAGER FOR CHROME

Get country flag of website IP address in your browser

Learn More
ADVERTISEMENT