Subnet Calculator
What is a Subnet?
In computer networking, a subnet (short for subnetwork) is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting. This is done for several reasons, including improved security, better organization, and more efficient use of IP addresses.
Computers that belong to the same subnet are addressed with a common, identical, most-significant bit-group in their IP address. This results in the logical division of an IP address into two fields: the network number (or routing prefix) and the rest field (or host identifier). CIDR (Classless Inter-Domain Routing) is the modern standard for specifying network prefixes, like 192.168.1.0/24
.
Key Terms Explained
- CIDR (Classless Inter-Domain Routing)
- The modern method for allocating IP addresses and routing. A CIDR address looks like
10.1.2.3/24
, where/24
is the prefix length indicating 24 bits are used for the network portion. - Subnet Mask
- A 32-bit number that separates the network portion of an IP address from the host portion. In binary, the network bits are all '1's and the host bits are all '0's. For example, a
/24
prefix has a subnet mask of255.255.255.0
. - Wildcard Mask
- The inverse of a subnet mask, used in some routing protocols and access control lists (ACLs). It specifies which bits of an IP address to check. For a mask of
255.255.255.0
, the wildcard is0.0.0.255
. - Network Address
- The first address in a subnet, which represents the network itself. Host devices cannot be assigned this address.
- Broadcast Address
- The last address in a subnet. Packets sent to this address are delivered to all hosts on that subnet. It cannot be assigned to a host device.
- VLSM (Variable Length Subnet Mask)
- A technique that allows network administrators to divide an IP address space into subnets of different sizes, which is highly efficient for networks with varying host requirements.
- Supernetting (Route Aggregation)
- The process of combining multiple smaller, contiguous network routes into a single, larger summary route. This reduces the size of routing tables and improves router performance.
How Subnetting Works — Step by Step
Example: Subnetting 192.168.10.0/24 into /26 Networks
Imagine you have the network 192.168.10.0/24
and you need to create four smaller networks for different departments.
- Determine the new prefix: To get 4 subnets, you need to borrow 2 bits from the host portion (since 22 = 4). The new prefix will be 24 + 2 =
/26
. - New Subnet Mask: A /26 prefix corresponds to the mask
255.255.255.192
. - Calculate the "Magic Number": The block size for our new subnets is 256 - 192 = 64. This means our subnets will start at 0, 64, 128, and 192 in the last octet.
- List the Subnets:
- Subnet 1:
192.168.10.0/26
(Range: 192.168.10.0 - 192.168.10.63) - Subnet 2:
192.168.10.64/26
(Range: 192.168.10.64 - 192.168.10.127) - Subnet 3:
192.168.10.128/26
(Range: 192.168.10.128 - 192.168.10.191) - Subnet 4:
192.168.10.192/26
(Range: 192.168.10.192 - 192.168.10.255)
- Subnet 1:
- Each
/26
subnet provides 2(32-26) - 2 = 62 usable host addresses.
Frequently Asked Questions (FAQ)
What is CIDR notation and how does it relate to subnet masks?
CIDR (Classless Inter-Domain Routing) notation is a compact way to represent a subnet mask. It consists of an IP address followed by a forward slash and a number (e.g., 192.168.1.0/24
). The number, called the prefix length, indicates how many leading bits of the IP address are part of the network portion. For example, /24
corresponds to the subnet mask 255.255.255.0
, as both represent 24 leading '1' bits in the mask.
How many hosts are in a /24, /26, /30 and /31 network?
The number of hosts depends on the number of host bits (32 minus the prefix length).
- /24 (8 host bits): 28 - 2 = 254 usable hosts.
- /26 (6 host bits): 26 - 2 = 62 usable hosts.
- /30 (2 host bits): 22 - 2 = 2 usable hosts, ideal for point-to-point links.
- /31 (1 host bit): Per RFC 3021, this is a special case for point-to-point links with 2 total addresses (no network/broadcast addresses), both of which are usable as hosts.
What is the broadcast address of 192.168.1.0/26?
For 192.168.1.0/26
, the network address is 192.168.1.0
. The prefix /26 leaves 6 bits for the host portion (32-26=6), meaning the subnet has 26 = 64 addresses. The range is 192.168.1.0 to 192.168.1.63. The broadcast address is the last address in this range, which is 192.168.1.63.
How do I plan subnets for multiple host-size requirements (VLSM)?
VLSM (Variable Length Subnet Mask) allows you to allocate IP address space efficiently. To plan, first list all your required subnets and the number of hosts needed for each. Sort this list from the largest host requirement to the smallest. Starting with your main address block, allocate the first, largest required subnet. Then, from the next available address, allocate the second-largest required subnet, and so on. This tool's VLSM Planner automates this entire process.
Can I aggregate multiple /24s into a larger prefix?
Yes, this is called supernetting or route aggregation. You can combine multiple smaller, contiguous networks into a single, larger network summary. For example, the four /24 networks 192.168.0.0/24
, 192.168.1.0/24
, 192.168.2.0/24
, and 192.168.3.0/24
can be aggregated into a single route: 192.168.0.0/22
. The networks must be contiguous and form a power-of-two block for perfect aggregation.
What is the difference between a supernet and a subnet?
A subnet is created by dividing a larger network into smaller, multiple pieces. This is done by 'borrowing' bits from the host portion of the address to create more network bits. A supernet is the opposite; it's created by combining multiple smaller, contiguous networks into one larger network. This is done by 'returning' bits to the host portion, resulting in a shorter prefix mask (e.g., aggregating /24s into a /22).
How does IPv6 subnetting differ from IPv4?
While the principles are similar (network vs. host portions), the scale is vastly different. A standard IPv6 subnet for end-user devices is a /64
, which contains an astronomical number of addresses (264). Subnetting in IPv6 typically involves carving up a larger allocation (like a /48
or /56
) into multiple /64
subnets, rather than calculating hosts per subnet. The focus is on creating a logical, hierarchical addressing plan, not conserving addresses.
How should I choose subnet sizes for a scalable network?
For scalability, always plan for future growth. A good rule of thumb is to calculate the number of hosts you need today and double it, then choose the next largest subnet size. For example, if you need 50 hosts, you could use a /26
(62 usable hosts), but a /25
(126 usable hosts) provides more room to grow. For infrastructure links like routers, use /30
or /31
. For user segments (VLANs), /24
is common but can be adjusted based on department size.