Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Cheat Sheet
  • CSS Cheat Sheet
  • JS Cheat Sheet
  • Bootstrap Cheat Sheet
  • jQuery Cheat Sheet
  • Angular Cheat Sheet
  • SDE Sheet
  • Facebook SDE Sheet
  • Amazon SDE Sheet
  • Apple SDE Sheet
  • Netflix SDE Sheet
  • Google SDE Sheet
  • Wipro SDE Sheet
  • Infosys SDE Sheet
  • TCS SDE Sheet
  • Cognizant SDE Sheet
  • HCL SDE Sheet
  • Mass Recruiters Sheet
  • Product-Based Coding Sheet
  • Company-Wise Practice Sheet
  • Love Babbar Sheet
Open In App
Next Article:
Git Cheat Sheet
Next article icon

Subnet Mask Cheat Sheet

Last Updated : 03 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

A Subnet Mask is a numerical value that describes a computer or device's how to divide an IP address into two parts: the network portion and the host portion. The network element identifies the network to which the computer belongs and the host part identifies the unique computer on that network. An IP address is made up of four digits separated by dots, for example, 255.255.255.0 and each number can be between 0 and 255, with higher values using more bits for the network and lesser values for the host. A subnet mask allows devices on the same network or across networks to interact with each other. Every system has a unquine IP address.

In this Subnetting Cheat Sheet, you'll learn all the basic to advanced subnetting concepts, including CIDR notation, and IPv4 subnet masks ranging from XX.XX.XX.XX/0 to XX.XX.XX.XX/32, IPv4 wildcard mask values, classification of IPv4 addresses from Class A to Class E, and more.

Subnet-CheatSheet

Additionally, In this Subnetting Mask Cheat Sheet, you will also explore private IP addresses, special IP addresses, and bogon IP addresses, further enhancing your knowledge of network addressing.

Table of Content

  • IPv4 Subnets (w/ Wildcard Mask Values)
  • Classification of IPV4 Address
  • Reserved IP Address
  • Private IPv4 Addresses
  • Special IPv4 Addresses
  • Bogon IPv4 Addresses

What is Subnetting?

Subnetting is the technique of dividing one big network into multiple small networks. Subnet makes the network more efficient and easy to maintain. Subnets provide a shorter path to network traffic without passing through unnecessary routers to reach their destinations.Subnetting makes network routing much more efficient.


How Does Subnetting Work?

Let's assume what happens when there is no subnetting in a Large network that has a million devices connected to them and they have their unique IP Address. Now, what happens when we send some information in that network from one device to another? In that case, our data/information passes through most of the unnecessary routers or devices until they find a destination device.

How Subnetting Works?
How Does Subnetting Works?

Now, think we divided the same network into smaller subnetworks. This helps make the routing of data more efficient. Instead of searching through millions of devices to find the right one, routers (check if the destination IP address falls within their range of subnet devices. If it does, they route the packet to the appropriate device. If it doesn't, they forward the packet to another router) can use something called a subnet mask to determine which subnetwork a device belongs to.

What is Classful Addressing and Classless Addressing?

In Classful Addressing, we divided IPV4 Network into 5 classes(Class A, Class B, Class C, Class D, Class E) of fixed length. In Classful addressing IP addresses are allocated according to the classes- A to E. In this Scheme, Network ID and Host ID changes depend on the class.

On the Other Hand, CIDR or Class Inter-Domain Routing was introduced in 1993 to replace classful addressing. It allows the user to use VLSM or Variable Length Subnet Masks. So, there is no such restriction of class in classless addressing. The wastage of IP addresses has been improved after CIDR Addressing.

What is CIDR?

CIDR or Class Inter-Domain Routing allows the user to use VLSM or Variable Length Subnet Masks in order to make IP address allocation and IP routing that allows more efficient use of IP addresses.

Rules for forming CIDR Blocks:

  • All IP addresses must be contiguous or sequential.(NID=network ID , HID=host ID)
  • The block size must be the power of 2 (2n). If the size of the block is the power of 2, then it will be easy to divide the Network. Finding out the Block Id is very easy if the block size is of the power of 2. Example: If the Block size is 25 then, Host Id will contain 5 bits and Network will contain 32 – 5 = 27 bits.
What is CIDR?
  • The first IP address of the Block must be evenly divisible by the size of the block. in simple words, the least significant part should always start with zeroes in Host Id. Since all the least significant bits of Host Id are zero, then we can use it as the Block Id part.

Example: Let's check whether the IP address block from 192.168.1.64 to 192.168.1.127 is a valid IP address block or not?

  • All the IP addresses in the block are contiguous.
  • Total number of IP addresses in the block is = 64 = 26
  • The first IP address in the block is 192.168.1.64. We can observe that the Host ID contains the last 6 bits, and in this case, the least significant 6 bits are not all zeros. Therefore, the first IP address is not evenly divisible by the size of the block.

As a result, this block does not satisfy the criteria for a valid IP address block, and therefore, it is not a valid IP block.

Working on IP Address Block

An IP address is a 32-bit unique address having an address space of 232. The IPv4 address is divided into two parts:

  1. Network ID
  2. Host ID.

For Example:- IP addresses belonging to class A are assigned to the networks that contain many hosts. 

  • The network ID is 8 bits long.
  • The host ID is 24 bits long.

The higher-order bit of the first octet in class A is always set to 0. The remaining 7 bits in the first octet are used to determine network ID. The 24 bits of host ID are used to determine the host in any network. The default subnet mask for Class A is 255.x.x.x. Therefore, class A has a total of:

2^7-2= 126 network ID(Here 2 address is subtracted because 0.0.0.0 and 127.x.y.z are special address. )

2^24 – 2 = 16,777,214 host ID

IP addresses belonging to class A range from 1.x.x.x – 126.x.x.x

How to Calculate CIDR Notation?

Here, step-by-step you can calculate the CIDR notation of any IP Address:

Step 1: First, find the IP address and the subnet mask. Ex:- 194.10.12.1(IP Address), 255.255.255.0 (Subnet Mask)

Step 2: Convert the subnet mask to binary. (255.255.255.0 -> 11111111.11111111.11111111.00000000)

Step 3: Count the number of consecutive 1s in the binary subnet mask.(11111111.11111111.11111111)

Step 4: Determine the CIDR prefix length.(24'ones)

Step 5: Write the CIDR notation. (194.10.12.1/24)

IPv4 Subnets (w/ Wildcard Mask Values)

Here in the below charts, we will see pre-defined subnet masks, followed by some explanations of what they mean.

CIDRSUBNET MASKWILDCARD MASK# OF IP ADDRESSES# OF USABLE IP ADDRESSES
/32255.255.255.2550.0.0.011
/31255.255.255.2540.0.0.122*
/30255.255.255.2520.0.0.342
/29255.255.255.2480.0.0.786
/28255.255.255.2400.0.0.151614
/27255.255.255.2240.0.0.313230
/26255.255.255.1920.0.0.636462
/25255.255.255.1280.0.0.127128126
/24255.255.255.00.0.0.255256254
/23255.255.254.00.0.1.255512510
/22255.255.252.00.0.3.25510241022
/21255.255.248.00.0.7.25520482046
/20255.255.240.00.0.15.25540964094
/19255.255.224.00.0.31.25581928190
/18255.255.192.00.0.63.25516,38416382
/17255.255.128.00.0.127.25532,76832766
/16255.255.0.00.0.255.25565,53665534
/15255.254.0.00.1.255.255131,072131070
/14255.252.0.00.3.255.255262,144262,142
/13255.248.0.00.7.255.255524,288524,286
/12255.240.0.00.15.255.2551,048,5761,048,574
/11255.224.0.00.31.255.2552,097,1522,097,150
/10255.192.0.00.63.255.2554,194,3044,194,302
/9255.128.0.00.127.255.2558,388,6088,388,606
/8255.0.0.00.255.255.25516,777,21616,777,214
/7254.0.0.01.255.255.25533,554,43233,554,430
/6252.0.0.03.255.255.25567,108,86467,108,862
/5248.0.0.07.255.255.255134,217,728134,217,726
/4240.0.0.015.255.255.255268,435,456268,435,454
/3224.0.0.031.255.255.255536,870,912536,870,910
/2192.0.0.063.255.255.2551,073,741,8241,073,741,822
/1128.0.0.0127.255.255.2552,147,483,6482,147,483,646
/00.0.0.0255.255.255.2554,294,967,2964,294,967,294

Classification of IPV4 Address

IPv4 addresses are classified into five classes: A, B, C, D, and E. The first octet(8 bits) of an IPv4 address determines the class of the address.

Classification of IP Addresses

Range

Number of Blocks

Representation in the subnet mask

Class A0.0.0.0-127.255.255.255128255.0.0.0/8
Class B128.0.0.0-191.255.255.25516,384255.255.0.0/16
Class C192.0.0.0-223.255.255.2552,097,152255.255.255.0/24
Class D224.0.0.0-239.255.255.255n/an/a
Class E240.0.0.0-255.255.255.255n/an/a

And here's a table of the decimal to binary conversions for subnet mask and wildcard octets:

SUBNET MASK

WILDCARD
00000000025511111111
1281000000012701111111
192110000006300111111
224111000003100011111
240111100001500001111
24811111000700000111
25211111100300000011
2541111111010000001
25511111111000000000

Reserved IP Address

Reserved IP addresses are a set of IP addresses that are not assigned to any specific device or network. 

Here are some examples of reserved IP address ranges:

Reserved IP Addresses

0.0.0.0/8This network
10.0.0.0/8Private IPv4 Address Block
100.64.0.0/10Carrier-grade NAT
127.0.0.0/8Loopback
127.0.53.53Name collision occurrence
169.254.0.0/16Link local
172.16.0.0/12Private IPv4 Address Block
192.0.0.0/24IETF protocol assignments
192.0.2.0/24TEST-NET-1
192.168.0.0/16Private IPv4 Address Block
198.18.0.0/15Network benchmark testing
198.51.100.0/24TEST-NET-2
255.255.255.255Limited Broadcast address

Private IPv4 Addresses

Private IPv4 addresses are a range of IP addresses that are not routable on the public internet. They are reserved for use within private networks, such as homes, businesses, and organizations. 

The range of private IPv4 addresses is:

Private IPv4 Addresses

Class A10.0.0.0 – 10.255.255.255
Class B172.16.0.0 – 172.31.255.255
Class c192.168.0.0 – 192.168.255.255

Special IPv4 Addresses

Special IPv4 addresses are a set of IP addresses, that serve specific purposes. These addresses are used for special functions and are not assigned to individual devices. 

Here are some examples of special IPv4 addresses:

Special IPv4 Addresses

Local Host127.0.0.0 – 127.255.255.255
APIPA169.254.0.0 – 169.254.255.255

Bogon IPv4 Addresses

A bogon IP address is an IP address that are not assigned or allocated to any specific entity or organization. Bogon addresses are typically used to filter or block suspicious or illegitimate network traffic. 

Here are some examples of bogon IPv4 address ranges:

Bogon IPv4 Address Range

Description

0.0.0.0/8Reserved address space
10.0.0.0/8Private network (RFC 1918)
100.64.0.0/10Shared address space (CGN)
127.0.0.0/8Loopback address
169.254.0.0/16Link-local address (Autoconfiguration)
172.16.0.0/12Private network (RFC 1918)
192.0.0.0/24Reserved address space used for documentation
192.0.2.0/24Reserved address space used for documentation
192.168.0.0/16Private network (RFC 1918)
198.51.100.0/24Reserved address space used for documentation
203.0.113.0/24Reserved address space used for documentation
240.0.0.0/4Reserved for future use or experimental purposes

Why learning Subnetting is Important?

Learning to subnet is important for a number of reasons, including:

  • Conserving IP addresses: Subnetting allows for the efficient use of limited IPv4 addresses by dividing a larger network into smaller networks, conserving IP addresses and facilitating better management.
  • Improving network performance: Subnetting reduces the size of broadcast domains, reducing network congestion and improving performance by limiting the scope of broadcast messages.
  • Enhancing network security: Subnetting isolates different parts of a network, improving security by preventing unauthorized access to sensitive data.
  • Simplifying network management: Subnetting makes it easier to identify and troubleshoot problems by isolating issues to specific subnets, simplifying network management and troubleshooting processes.
  • Solitary organization: Gadgets on the equivalent subnet can speak with one another straightforwardly without going through a switch or other systems administration gadget.

By learning subnetting, you gain a comprehensive understanding of network design, management, and troubleshooting, making you a valuable asset in the field of networking.

Summary

Alright, wrapping it up, subnetting is pretty much a crucial skill for network admins and IT professionals. It's all about managing and dishing out IP addresses in networks like a pro. This subnet cheat sheet? It's your new best friend. It's got everything you need to know about subnetting, from getting your head around IP addresses and subnet masks to the lingo like CIDR notation and VLSM. Just follow the guide, use the formulas and tables, and subnetting will be a walk in the park. Keep at it, and you'll be a subnetting master in no time, creating slick network designs, using addresses like a boss, and boosting network performance.Limitations of subnetting. Communication between one subnet to another subnet requires a router. A poorly configured or fatally failed router can significantly impact your organization’s network.


Conclusion

Mastering subnetting is essential for network administrators and IT professionals alike. This cheat sheet provides a handy reference for understanding and calculating subnet masks, ensuring efficient network management and troubleshooting. By using this resource, you can streamline your subnetting processes, optimize network performance, and enhance overall security.


Next Article
Git Cheat Sheet

S

shubhamthakur05
Improve
Article Tags :
  • Computer Networks
  • GFG Sheets
  • Cheat Sheet

Similar Reads

    Geeksforgeeks Cheatsheets - All Coding Cheat Sheets Collections
    Cheatsheets are short documents that contain all the most essential information about a specific technology in short, such as its syntax, commands, functions, or its features. Sheets are designed to help users to learn quickly and these Sheets are given the basics Overview of the technology without
    4 min read
    Subnet Mask Cheat Sheet
    A Subnet Mask is a numerical value that describes a computer or device's how to divide an IP address into two parts: the network portion and the host portion. The network element identifies the network to which the computer belongs and the host part identifies the unique computer on that network. An
    9 min read
    Git Cheat Sheet
    Git Cheat Sheet is a comprehensive quick guide for learning Git concepts, from very basic to advanced levels. By this Git Cheat Sheet, our aim is to provide a handy reference tool for both beginners and experienced developers/DevOps engineers. This Git Cheat Sheet not only makes it easier for newcom
    10 min read
    NumPy Cheat Sheet: Beginner to Advanced (PDF)
    NumPy stands for Numerical Python. It is one of the most important foundational packages for numerical computing & data analysis in Python. Most computational packages providing scientific functionality use NumPy’s array objects as the lingua franca for data exchange. In this Numpy Cheat sheet f
    15+ min read
    Linux Commands Cheat Sheet
    Linux, often associated with being a complex operating system primarily used by developers, may not necessarily fit that description entirely. While it can initially appear challenging for beginners, once you immerse yourself in the Linux world, you may find it difficult to return to your previous W
    13 min read
    Pandas Cheat Sheet for Data Science in Python
    Pandas is a powerful and versatile library that allows you to work with data in Python. It offers a range of features and functions that make data analysis fast, easy, and efficient. Whether you are a data scientist, analyst, or engineer, Pandas can help you handle large datasets, perform complex op
    15+ min read
    Java Cheat Sheet
    Java is a programming language and platform that has been widely used since its development by James Gosling in 1991. It follows the Object-oriented Programming concept and can run programs written on any OS platform. Java is a high-level, object-oriented, secure, robust, platform-independent, multi
    15+ min read
    C++ STL Cheat Sheet
    The C++ STL Cheat Sheet provides short and concise notes on Standard Template Library (STL) in C++. Designed for programmers that want to quickly go through key STL concepts, the STL cheatsheet covers the concepts such as vectors and other containers, iterators, functors, etc., with their syntax and
    15+ min read
    Docker Cheat Sheet : Complete Guide (2024)
    Docker is a very popular tool introduced to make it easier for developers to create, deploy, and run applications using containers. A container is a utility provided by Docker to package and run an application in a loosely isolated environment. Containers are lightweight and contain everything neede
    10 min read
    C++ Cheatsheet
    This is a C++ programming cheat sheet. It is useful for beginners and intermediates looking to learn or revise the concepts of C++ programming. While learning a new language, it feels annoying to switch pages and find different websites for different concepts that are easily understandable. You can
    15 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences