Beginner
foundationsStart here if subnetting is new. This builds the vocabulary everything else depends on.
What Is an IP Address?
The core concept β every device needs one
βΆ
An IP address (Internet Protocol address) is a numeric label assigned to every device on a network, so it can send and receive data. Think of it like a street address β without it, data has no idea where to go or where it came from.
There are two versions in use today:
IPv4β the classic format, written as four numbers separated by dots, e.g.192.168.1.10. This is what almost all of this guide covers, and what you'll deal with daily on TFhost servers.IPv6β the newer, much larger address space, written in hex groups, e.g.2001:0db8:85a3::8a2e:0370:7334. Built because IPv4 has "run out" of addresses globally.
IPv4 Structure β Octets & Binary
Why an IP looks like x.x.x.x
βΆ
An IPv4 address is a 32-bit number, split into four 8-bit sections called octets, separated by dots. Each octet ranges from 0β255, because 8 bits can represent 2βΈ = 256 values (0 through 255).
This is the single most important mental model for subnetting: everything is binary underneath. The decimal dotted format is just a human-friendly way of reading four 8-bit binary blocks.
| Binary bit value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Position | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
Public vs Private IP Addresses
Which ranges are reachable from the internet
βΆ
Private IPs are reserved ranges meant only for use inside local networks (offices, home LANs, internal server VLANs). They are not routable on the public internet.
| Range | CIDR | Typical use |
|---|---|---|
| 10.0.0.0 β 10.255.255.255 | 10.0.0.0/8 | Large internal networks |
| 172.16.0.0 β 172.31.255.255 | 172.16.0.0/12 | Medium networks, Docker defaults |
| 192.168.0.0 β 192.168.255.255 | 192.168.0.0/16 | Home/office routers |
Public IPs are everything else β globally unique and routable, assigned by your ISP or a regional registry (like AFRINIC for Nigeria). This is the type of IP a hosting server's main network interface typically has, e.g. 160.119.196.135 from your earlier example.
IP Address Classes (A / B / C / D / E)
The old classful system β still useful for intuition
βΆ
Before CIDR (which you'll use in practice), IPv4 addresses were split into "classes" based on their first octet. Modern networking doesn't strictly follow this anymore, but it's still how a lot of default subnet masks got their historical starting point.
| Class | First octet range | Default mask | Use |
|---|---|---|---|
| A | 1 β 126 | 255.0.0.0 (/8) | Huge networks |
| B | 128 β 191 | 255.255.0.0 (/16) | Medium-large networks |
| C | 192 β 223 | 255.255.255.0 (/24) | Small networks |
| D | 224 β 239 | β | Multicast |
| E | 240 β 255 | β | Reserved / experimental |
Default Gateway & Loopback
Two special addresses you'll see constantly
βΆ
The default gateway is the IP address of the router that a device sends traffic to whenever the destination isn't on its own local subnet β basically, "the door out of this network."
.129 in a /26). That's just a convention, not a rule. The gateway can be configured as any usable address in the subnet's range β the actual network/broadcast boundaries are determined purely by the subnet mask, never by where the gateway happens to sit.Loopback (127.0.0.1, hostname localhost) always refers to "this machine" β used for testing services locally without touching the network.
Intermediate
subnetting coreThis is where actual subnetting math lives β the part that trips people up without a mental model.
Subnet Masks Explained
How a mask splits an address into network + host
βΆ
A subnet mask tells devices which part of an IP address is the network portion (shared by every device in that subnet) and which part is the host portion (unique to each device).
In binary, a mask is a run of 1s followed by a run of 0s. The 1s mark "network bits," the 0s mark "host bits."
Here, the last octet has 2 bits set to 1 (contributing to network) and 6 bits set to 0 (host bits). Those 6 host bits give you 2βΆ = 64 total addresses in the block β which matches what we calculated for the 160.119.196.135 example earlier.
| Dotted mask | Binary (last relevant octet) | Host bits | Block size |
|---|---|---|---|
| 255.255.255.0 | 00000000 | 8 | 256 |
| 255.255.255.128 | 10000000 | 7 | 128 |
| 255.255.255.192 | 11000000 | 6 | 64 |
| 255.255.255.224 | 11100000 | 5 | 32 |
| 255.255.255.240 | 11110000 | 4 | 16 |
| 255.255.255.248 | 11111000 | 3 | 8 |
| 255.255.255.252 | 11111100 | 2 | 4 |
CIDR Notation
The /24, /26, /30 shorthand
βΆ
CIDR (Classless Inter-Domain Routing) notation writes a subnet mask as a slash followed by the number of network bits β e.g. /26 means 26 bits are network bits, leaving 32 β 26 = 6 host bits.
| CIDR | Subnet mask | Host bits | Total addresses | Usable hosts |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 8 | 256 | 254 |
| /25 | 255.255.255.128 | 7 | 128 | 126 |
| /26 | 255.255.255.192 | 6 | 64 | 62 |
| /27 | 255.255.255.224 | 5 | 32 | 30 |
| /28 | 255.255.255.240 | 4 | 16 | 14 |
| /29 | 255.255.255.248 | 3 | 8 | 6 |
| /30 | 255.255.255.252 | 2 | 4 | 2 (point-to-point links) |
You'll write CIDR constantly β firewall rules, VPS provisioning, WHMCS IP allocations, cloud security groups all use it. 160.119.196.135/26 is the same information as an IP + 255.255.255.192, just more compact.
Network Address & Broadcast Address
The two addresses you can never assign to a device
βΆ
Every subnet block "reserves" its first and last address:
- Network address β the very first address in the block (all host bits = 0). It identifies the subnet itself, not a device.
- Broadcast address β the very last address in the block (all host bits = 1). Sending a packet here reaches every device on that subnet at once.
Neither can be assigned to a server, router interface, or workstation. That's why usable hosts = block size β 2.
Calculating a Usable Range by Hand
The method β step by step, no calculator
βΆ
This is the exact process for the question that started this whole page β given an IP and a mask, find the network, broadcast, and usable range.
- Find the block size from the mask's last non-255, non-0 octet. For
255.255.255.192: 256 β 192 = 64. - Find which block the IP falls in by dividing the relevant octet by the block size and rounding down, then multiplying back. For
135: 135 Γ· 64 = 2.1 β block starts at 2 Γ 64 = 128. - Network address = block start β
160.119.196.128 - Broadcast address = network + block size β 1 β 128 + 64 β 1 = 191 β
160.119.196.191 - Usable range = network+1 to broadcastβ1 β
160.119.196.129 β 160.119.196.190
160.119.196.135 sits inside network 160.119.196.128/26, not .134 β 134 isn't a multiple of 64, so it can never be a valid network address for a /26.
Common Subnet Sizes β Cheat Sheet
Print this one out
βΆ
| CIDR | Mask | Block boundaries (last octet) | Usable hosts |
|---|---|---|---|
| /30 | .252 | 0,4,8,12,16...252 | 2 |
| /29 | .248 | 0,8,16,24,32...248 | 6 |
| /28 | .240 | 0,16,32,48...240 | 14 |
| /27 | .224 | 0,32,64,96,128,160,192,224 | 30 |
| /26 | .192 | 0,64,128,192 | 62 |
| /25 | .128 | 0,128 | 126 |
| /24 | .0 | 0 | 254 |
Binary β Decimal Conversion
The manual skill behind every shortcut above
βΆ
To convert decimal β binary for one octet, repeatedly check off the largest power of 2 that fits:
To go binary β decimal, just add up the powers of 2 where there's a 1: 128+4+2+1 = 135.
Advanced
expert territoryDesigning address space, not just reading it β the skills for planning real infrastructure.
VLSM β Variable Length Subnet Masking
Different subnet sizes carved from the same block
βΆ
VLSM means you don't have to give every subnet the same size mask. You carve a large address block into subnets of exactly the size each segment needs β a /30 for a router link, a /28 for a small VLAN, a /24 for a big one β instead of wasting a uniform /24 everywhere.
Example: You're given 160.119.196.0/24 and need: a 100-host LAN, a 40-host LAN, a 10-host LAN, and 2 point-to-point router links.
Rule of thumb: allocate biggest subnets first, so smaller ones fit cleanly into the leftover space without fragmenting the block.
Worked Practice Problems
Try these, then check your work
βΆ
Problem 1: IP 41.203.88.50, mask 255.255.255.224 (/27). Find network, broadcast, usable range.
Problem 2: IP 10.10.5.200, mask 255.255.255.240 (/28). Find network, broadcast, usable range.
Problem 3: How many /29 subnets fit inside a /24?
Route Summarization / Supernetting
Combining many small networks into one route
βΆ
Supernetting is the reverse of subnetting: combining several contiguous smaller networks into one larger route announcement, so routers carry fewer entries in their routing tables.
Example: 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24 can be summarized as a single 192.168.0.0/22 β because those four /24s are contiguous and align on a /22 boundary (a block of 1024 addresses starting at a multiple of 4 in the third octet).
NAT β Network Address Translation
How private IPs reach the public internet
βΆ
NAT lets a router rewrite the source (or destination) IP of packets as they cross between a private network and the public internet, so many private-IP devices can share one public IP.
- SNAT (Source NAT) β rewrites the outgoing source IP, typically used so an entire office LAN shares one public IP to browse the internet.
- DNAT (Destination NAT / port forwarding) β rewrites the incoming destination IP, used to expose an internal server (e.g. a VPS behind a private subnet) on a specific public IP/port.
- 1:1 NAT β maps one private IP directly to one public IP, common in hosting environments giving each VM its own reachable address.
Common Subnetting Mistakes
The misconceptions that cause real outages
βΆ
- Assuming the gateway defines the network address. It doesn't β the mask does. A gateway can legally sit anywhere in the usable range, not just "2nd IP" or "1st IP."
- Forgetting the network/broadcast reservation. Assigning the first or last address of a block to a device will cause routing failures β those two addresses are never usable.
- Mixing up mask and wildcard mask. Some devices (Cisco ACLs) want a wildcard mask, which is the inverse of a subnet mask β e.g.
/26's subnet mask is255.255.255.192, but its wildcard mask is0.0.0.63. - Treating VLSM subnets as independent /24s. If you carve a /24 into VLSM chunks, remember the smaller subnets are not separate β they share the parent block's addressing and must not overlap.
- Not double-checking block alignment. A network address must always be an exact multiple of its block size (0, 64, 128, 192 for a /26). If it isn't, the subnet boundary was calculated wrong.
Live Subnet Calculator
toolPunt an IP + mask (or CIDR) in, get network, broadcast, usable range, and host count out. Same logic as the worked examples above.