IP Addresses, Subnets, and CIDR: A Complete Guide to Networking Fundamentals

A systematic overview of IP addresses, subnets, and CIDR, with subnet calculation and troubleshooting methods.
This article covers the fundamentals of IP addresses, subnets, and CIDR. An IP address is the unique identifier of a network device, consisting of a network portion and a host portion. Subnet masks divide the network and host portions, and subnetting improves management efficiency. CIDR notation combines the IP and mask, simplifying address allocation and routing. The article demonstrates a four-step method to calculate subnets and hosts from CIDR, illustrates real-world application with department network planning, and discusses common subnet issues (over-subnetting, mask errors, IP conflicts) and troubleshooting tools (ping, arp), emphasizing regular audits and documentation.
Why You Need to Understand IP Addresses, Subnets, and CIDR
Every device connected to a network needs a unique identifier—an IP address. It handles packet routing and is the cornerstone of communication on both the internet and local networks. However, knowing an IP address alone isn't enough: dividing networks and efficiently allocating addresses both depend on subnets and CIDR (Classless Inter-Domain Routing) notation. This article builds on a foundational tutorial to systematically cover these concepts, adding practical calculations and troubleshooting approaches.

IP Addresses: The ID Card of Network Devices
IP addresses are typically written in dotted-decimal format, such as 192.168.1.1. They consist of a network portion and a host portion, with the specific division depending on the subnet mask. Understanding this is a prerequisite for everything that follows.
Before discussing subnetting, it's worth distinguishing IPv4 from IPv6. All examples in this article are based on IPv4, which uses 32-bit addresses typically represented as four decimal numbers from 0-255 (dotted-decimal). IPv6 uses 128-bit addresses written as eight groups of hexadecimal numbers (e.g., 2001:db8::1), greatly expanding the address space and simplifying the header structure. Although the two differ significantly in representation and scale, the concepts of network and host portions and the logic of subnetting apply equally. Understanding IPv4 is the foundation for mastering subnets and CIDR, while IPv6 represents the future direction of networking.
Subnets and Subnet Masks: Breaking Things Down
A subnet divides a large network into smaller, more manageable segments. A subnet mask (such as 255.255.255.0) identifies which part of an IP address is the network and which is the host. For example, with IP 192.168.1.1 and mask 255.255.255.0, the first three octets (192.168.1) form the network portion and the last octet (1) is the host portion. This means devices in the range 192.168.1.0 to 192.168.1.255 all belong to the same subnet.
The network address and broadcast address are two reserved addresses within a subnet that cannot be assigned to hosts. The network address is the address where all host bits are 0 (such as 192.168.1.0 in 192.168.1.0/24), used to identify the subnet itself; the broadcast address is the address where all host bits are 1 (such as 192.168.1.255/24), used to send data to all devices in the subnet. Therefore, the number of assignable hosts in a subnet equals 2 to the power of the number of host bits, minus 2. For example, /24 has 8 host bits and can assign 254 addresses; /28 has 4 host bits and can assign 14 addresses. Correctly identifying these two addresses is key to subnet calculation and troubleshooting.
CIDR: Simplifying Subnet Expression
CIDR notation combines an IP address and subnet mask into a shorthand, such as 192.168.1.0/24 representing the mask 255.255.255.0. The number after the slash is the number of bits in the network portion. CIDR's advantages lie in more efficient address allocation and more concise routing: /24 can accommodate 254 hosts (192.168.1.1 to 192.168.1.254), while /16 can support up to 65,534 hosts.
Classless Inter-Domain Routing (CIDR) was introduced in 1993 to replace traditional classful IP addresses (Class A, B, C), aiming to alleviate IPv4 address exhaustion and reduce routing table size. CIDR allows arbitrary-length prefixes to be allocated on demand, no longer constrained by fixed classes. For example, an organization can request a /22 address block rather than an entire Class B address. Additionally, CIDR supports route aggregation, combining multiple contiguous subnets into a single routing entry, thereby reducing the number of entries in global routing tables and improving routing efficiency.
Calculating Subnets and Hosts: The Four-Step Method
Given a CIDR, follow these steps to calculate:
- Convert to subnet mask: e.g.,
/24→255.255.255.0. - Determine the number of network bits:
/24uses 24 bits for the network, leaving 8 bits for hosts. - Calculate the number of subnets: the network bits can be divided into
2^8 = 256subnets (the original example; actual depends on the initial network). - Calculate hosts per subnet:
2^8 - 2 = 254hosts (subtracting the network address and broadcast address).
For example, /27 corresponds to the mask 255.255.255.224, with 27 network bits and 5 host bits. Each subnet can assign 2^5 - 2 = 30 hosts, for a total of 2^3 = 8 subnets.
Hands-On: Planning Department Networks with CIDR
Suppose a company needs to allocate IPs for seven departments. Choose /28 (mask 255.255.255.240) with 4 host bits, giving each subnet 2^4 - 2 = 14 usable host addresses. If the network address is 192.168.1.0, the subnets are 192.168.1.0/28, 192.168.1.16/28, 192.168.1.32/28... up to 192.168.1.60/28. Each department gets one subnet—flexible and efficient.
Common Subnet Problems and Troubleshooting
Improper subnetting can cause performance issues. Over-subnetting wastes IP addresses, so plan based on the actual number of devices. Incorrect subnet mask configurations can prevent devices from communicating. Additionally, IP address conflicts (two devices using the same IP) can cause connectivity failures and can be diagnosed using ping and arp tools. Regular audits and documented subnet plans help maintain network stability.
VLSM (Variable Length Subnet Mask) allows different subnet mask lengths within the same major network, allocating addresses according to each subnet's actual host requirements and avoiding waste. For example, a department with 100 devices can use /25 (126 usable addresses), while a department with only 10 devices can use /28 (14 usable addresses). Combined with CIDR, VLSM enables highly flexible address planning and is a common technique in modern network design.
Key Takeaways
- An IP address is the unique identifier for a device on a network.
- Subnets divide a network into smaller segments for easier management.
- CIDR notation simplifies subnet management by combining the IP and mask into one.
- Calculating subnets and hosts requires understanding network bits and host bits.
- CIDR enables efficient IP allocation.
Related articles

Free Unlimited Claude Code Solution: Agnes AI + CC Switch Setup Guide
No paid subscription needed — pair the free AI platform Agnes AI with the open-source tool CC Switch to provide a backend for Claude Code, enabling unlimited free calls to text, image, and video models. This guide covers the full setup, test results, and usage boundaries.

A Complete Zero-Cost Guide to Getting Started with Claude Code for Beginners in China
A beginner's guide to Claude Code for users in China: two installation methods (command line and IDE plugin), full configuration steps for replacing the official API with the free domestic LongCat model, and a hands-on demo of building a small tool with natural language, plus tips.

When the NSA Gets Involved: The AI Supply Chain Crisis Behind Open-Source CVEs and API Key Hijacking
Multiple open-source projects disclosed severe CVEs in one day, PHP flaws alarmed the FBI, and Railway and OpenCode were breached with API keys stolen. This article breaks down the vulnerability window, AI-accelerated exploitation, and the AI supply chain crisis behind the API key black market, with a developer defense checklist.