CampusFlow

Subnetting

Subnetting divides a large network into smaller sub-networks (subnets). It improves security, reduces broadcast traffic, and makes efficient use of IP addresses.

Key Formulas

2ⁿ

Number of Subnets

n = borrowed bits

2ʰ - 2

Usable Hosts/Subnet

h = remaining host bits

256 - mask

Block Size

mask = last non-255 octet

Step-by-Step Subnetting Process

1

Determine the IP class

Identify if the IP is Class A, B, or C to know the default subnet mask.

2

Determine subnets needed

Calculate how many subnets are required. Use formula: 2^n ≥ subnets needed (n = borrowed bits).

3

Borrow bits from host portion

Borrow bits from the host part to create subnet bits. Each borrowed bit doubles the number of subnets.

4

Calculate new subnet mask

Add borrowed bits to the default mask. E.g., /24 + 2 bits = /26 (255.255.255.192).

5

Calculate hosts per subnet

Hosts = 2^(remaining host bits) - 2 (subtract network and broadcast addresses).

6

List subnet ranges

Block size = 256 - last octet of mask. Subnets start at multiples of block size.

Worked Example

Given: 192.168.10.0/244 subnets needed

• Borrow 2 bits → 2² = 4 subnets ✓

• New prefix: /26 | New mask: 255.255.255.192

• Block size: 256 - 192 = 64

• Hosts per subnet: 2⁶ - 2 = 62 usable hosts

SubnetNetwork AddressFirst HostLast HostBroadcast
Subnet 1192.168.10.0192.168.10.1192.168.10.62192.168.10.63
Subnet 2192.168.10.64192.168.10.65192.168.10.126192.168.10.127
Subnet 3192.168.10.128192.168.10.129192.168.10.190192.168.10.191
Subnet 4192.168.10.192192.168.10.193192.168.10.254192.168.10.255

CIDR Quick Reference

CIDRSubnet MaskHostsBlock Size
/8255.0.0.016,777,214
/16255.255.0.065,534
/24255.255.255.0254256
/25255.255.255.128126128
/26255.255.255.1926264
/27255.255.255.2243032
/28255.255.255.2401416
/29255.255.255.24868
/30255.255.255.25224

Interview Questions

Q: Why do we subtract 2 from usable hosts?

One address is the network address (all host bits = 0) and one is the broadcast address (all host bits = 1). Neither can be assigned to a host.

Q: What is VLSM?

Variable Length Subnet Masking — allows different subnets to have different sizes, making more efficient use of IP address space.

Q: What is CIDR?

Classless Inter-Domain Routing — uses prefix notation (/n) instead of class-based masks, allowing flexible allocation of IP addresses.

Q: How many subnets does /26 create from a /24?

4 subnets (2 borrowed bits = 2² = 4), each with 62 usable hosts.