IPv4

Subnetting Explained — How to Subnet an IP Address Step by Step

G Gurpreet Singh August 28, 2026 5 min read
A /26 subnet mask in binary with the 24 network bits, 2 borrowed bits and 6 host bits colour-coded, beside the magic number calculation 256 minus 192 equals 64 and the resulting blocks

Subnetting is dividing one IP network into several smaller networks. You do it by borrowing bits from the host portion of the address and using them to identify subnets instead.

That single sentence is the whole concept. Everything else — the masks, the charts, the exam questions — follows from it.

Why Subnet at All?

  • Smaller broadcast domains. A flat /16 with 65,000 hosts means every device processes every broadcast. See collision and broadcast domains.
  • Security boundaries. Traffic between subnets must cross a router, where you can filter it with an ACL.
  • Address efficiency. A point-to-point WAN link needs 2 addresses, not 254.
  • Fault isolation. A broadcast storm stays inside one subnet.

The Only Numbers You Need to Memorise

Within an octet, each bit position has a fixed value:

Bit12345678
Value1286432168421
Running mask128192224240248252254255

The second row is the mask octet after borrowing that many bits. A subnet mask octet can only ever be one of those nine values (including 0) — because mask bits are contiguous from the left. If you ever calculate a mask octet of 100 or 200, you have made an arithmetic error.

How Borrowing Bits Works

Take 192.168.1.0/24. The mask is 255.255.255.0, so 24 bits are network and 8 are host:

192.168.1.0     11000000.10101000.00000001.00000000
255.255.255.0   11111111.11111111.11111111.00000000
                |------- network (24) ------||host(8)|

Borrow 2 host bits for subnetting and you get a /26:

255.255.255.192 11111111.11111111.11111111.11000000
                |------- network (26) --------||host|
                                             ^^
                                      borrowed bits

Two borrowed bits give 2² = 4 subnets, and 6 host bits remain, giving 2⁶ − 2 = 62 usable hosts each.

FormulaMeaning
2borrowed bitsNumber of subnets
2host bits − 2Usable hosts per subnet
256 − mask octetBlock size (the magic number)

Why minus 2?

Every subnet loses two addresses: the one with all host bits 0 is the network address, and the one with all host bits 1 is the broadcast address. Neither can be assigned to a device.

The Magic Number Method

This is how experienced engineers subnet in their head. Once you understand the binary, you only need one subtraction.

  1. Find the interesting octet — the one where the mask is neither 255 nor 0.
  2. Magic number = 256 − that mask octet. This is your block size.
  3. Count up in blocks from 0 in that octet. Those are your network addresses.
  4. Broadcast = next network − 1.
  5. Usable range = network + 1 to broadcast − 1.

Worked example: 192.168.1.0/26

Mask:              255.255.255.192
Interesting octet: 4th (192)
Magic number:      256 - 192 = 64
Blocks:            0, 64, 128, 192
SubnetNetworkFirst hostLast hostBroadcast
1192.168.1.0192.168.1.1192.168.1.62192.168.1.63
2192.168.1.64192.168.1.65192.168.1.126192.168.1.127
3192.168.1.128192.168.1.129192.168.1.190192.168.1.191
4192.168.1.192192.168.1.193192.168.1.254192.168.1.255

Worked example: which subnet is 172.16.68.130/28 in?

/28 -> 255.255.255.240
Interesting octet: 4th (240)
Magic number: 256 - 240 = 16
Blocks: 0, 16, 32, 48, 64, 80, 96, 112, 128, 144 ...

130 falls between 128 and 144.
Address
Network172.16.68.128
First host172.16.68.129
Our host172.16.68.130
Last host172.16.68.142
Broadcast172.16.68.143

When the interesting octet is the third

The method is identical — the block size just applies one octet to the left. For 10.20.0.0/22:

/22 -> 255.255.252.0
Interesting octet: 3rd (252)
Magic number: 256 - 252 = 4
Blocks in the 3rd octet: 0, 4, 8, 12, 16 ...

10.20.0.0   -> hosts 10.20.0.1 - 10.20.3.254,  broadcast 10.20.3.255
10.20.4.0   -> hosts 10.20.4.1 - 10.20.7.254,  broadcast 10.20.7.255
10.20.8.0   -> hosts 10.20.8.1 - 10.20.11.254, broadcast 10.20.11.255

Note the host range spans several third-octet values. A /22 is four /24s joined together — 1,022 usable hosts.

Reference Table

CIDRSubnet maskBlock sizeUsable hostsTypical use
/24255.255.255.0256254Standard office VLAN
/25255.255.255.128128126Split a /24 in two
/26255.255.255.1926462Small department
/27255.255.255.2243230Small office, IoT VLAN
/28255.255.255.2401614Server cluster, DMZ
/29255.255.255.24886Small server group
/30255.255.255.25242Point-to-point WAN links
/31255.255.255.25422 (RFC 3021)Point-to-point, no network/broadcast
/32255.255.255.25511Loopback, host route

The /30 is worth knowing cold — it is the classic WAN link subnet, giving exactly the two addresses a point-to-point link needs. /31 is the modern improvement: RFC 3021 allows point-to-point links to skip the network and broadcast addresses entirely, so a /31 also gives 2 usable addresses while consuming half the space.

Our subnet calculator works any of these out instantly, and the IP to binary converter shows the bit-level view while you are learning.

Subnetting a Real Network

You are given 192.168.10.0/24 and need:

  • Sales — 50 hosts
  • Engineering — 25 hosts
  • Management — 10 hosts
  • WAN link to the branch — 2 hosts

Always allocate largest first, or you will fragment the space and run out.

DepartmentNeedsSubnetMaskUsableRange
Sales50192.168.10.0/26255.255.255.19262.1 – .62
Engineering25192.168.10.64/27255.255.255.22430.65 – .94
Management10192.168.10.96/28255.255.255.24014.97 – .110
WAN link2192.168.10.112/30255.255.255.2522.113 – .114

Everything from 192.168.10.116 upward is still free for growth. Using different mask lengths within one network like this is VLSM — see VLSM explained for the full method.

Mistakes That Cost Marks and Cause Outages

Assigning the network or broadcast address to a host. 192.168.1.64/26 is a network address, not a usable host. Devices configured with it will not communicate.

Forgetting the mask when checking “same subnet”. 192.168.1.100 and 192.168.1.200 are in the same subnet with a /24 but different subnets with a /25. Two hosts only talk directly when their network portions match — otherwise traffic goes to the gateway.

Overlapping subnets. 192.168.1.0/25 and 192.168.1.0/26 overlap. Routing becomes unpredictable, because longest-prefix match will silently prefer the /26.

Subnetting on a non-boundary. A subnet must start on a multiple of its block size. 192.168.1.100/26 is invalid — with a block size of 64, valid networks are .0, .64, .128 and .192 only.

Mismatched masks on the same segment. One host on /24 and another on /25 on the same wire produces asymmetric reachability: one can reach the other but not the reverse. It is a genuinely confusing fault to diagnose.

Practise Until It Is Automatic

Subnetting is a skill, not knowledge — you learn it by repetition until the magic number is instant. Work through our subnetting practice questions, and keep the subnetting cheat sheet beside you until you no longer need it.

Frequently Asked Questions

What is subnetting in simple terms?

Splitting one large network into several smaller ones by borrowing bits from the host portion of the address and using them to identify subnets.

What is the magic number in subnetting?

256 minus the interesting mask octet. It is the block size — the increment between consecutive subnet addresses. For a /26 (mask 192), the magic number is 64, so subnets start at 0, 64, 128 and 192.

Why do you subtract 2 from the host count?

The all-zeros host address is the network address and the all-ones is the broadcast address. Neither can be assigned to a device, so a /24 gives 254 usable hosts rather than 256.

How many subnets do I get from borrowing 3 bits?

2³ = 8 subnets. Each borrowed bit doubles the number of subnets and halves the hosts in each.

What is the difference between a /24 and a /25?

A /24 is one network of 254 usable hosts. A /25 splits that same space into two networks of 126 hosts each, with block size 128 — so they start at .0 and .128.

Can two subnets talk to each other?

Only through a router or a Layer 3 switch. Subnets are separate broadcast domains by design; a device compares its own network portion against the destination’s and sends anything that does not match to its default gateway.

Is subnetting the same as VLANs?

No. A VLAN is a Layer 2 broadcast domain; a subnet is a Layer 3 address range. In practice they are mapped one-to-one — one VLAN, one subnet — but they are different mechanisms. See VLAN vs subnet.

GU
Written by

Gurpreet Singh

Hey! I"m Gurpreet Singh and I Have 7+ Years of experience in the Network & Security Domain as well as the Cloud Infra Domain. I am Certified with Cisco ( CCNA ), CheckPoint ( CCSA ), 1xAWS, 3xAZURE, and 3xNSE. So I love to share my tech knowledge with you.

Leave a Reply

Your email address will not be published. Required fields are marked *