IP Addressing, Subnet Mask, CIDR & Subnetting Explained: A Beginner’s Guide



1. What is an IP Address?

An IP (Internet Protocol) address is like your computer's home address on a network. Just as the postal system uses home addresses to deliver mail, networks use IP addresses to deliver data.

Example: 192.168.1.10

That’s called dotted decimal notation, and while it looks like 4 decimal numbers, under the hood each number (called an octet) is actually 8 bits (1 byte).

2. Breakdown of 4 Octets:

Octet Decimal Value Binary Equivalent Bits
1 192 11000000 8
2 168 10101000 8
3 1 00000001 8
4 10 00001010 8

Total = 8 + 8 + 8 + 8 = 32 bits

3. How to convert Decimal notation to Binary:

Each binary digit (bit) represents a power of 2, from left (highest) to right (lowest):

Bit Position 7     6     5     4     3     2     1     0
Place Value 128     64     32     16     8     4     2     1

Let's see how to convert Decimal 192 to Binary.

✅ Step-by-Step for 192:

Start with the highest place value (128) and work down:

  1. 192 ≥ 128 → ✅
    → Write 1, subtract 128 → 192 - 128 = 64

  2. 64 ≥ 64 → ✅
    → Write 1, subtract 64 → 64 - 64 = 0

Now all remaining place values are not needed, so write 0s.


Place Value 128     64     32     16     8     4     2     1
Fits in 192?                                   
Binary Digit 1     1     0     0     0     0 0 0

🔢 Final Answer: 192 = 11000000


4. Types of IP Addresses:

IPv4: Most common, 32-bit (e.g., 192.168.1.10)

IPv6: Newer, 128-bit (e.g., 2001:0db8:85a3::8a2e:0370:7334) — skip deep dive for now.

5. IP Address Classes:

1. The below table breaks down the five classes of IP addresses—A, B, C, D, and E—highlighting their IP range, address space, default subnet mask, and CIDR notation. 



This table offers a quick overview of the five IP address classes—A, B, C, D, and E—along with key details:

  • IP Range: The starting and ending IPs within each class.

  • Address Space: Total number of usable IP addresses in that class.

  • Subnet Mask: Defines which portion of the IP is the network vs. host.

  • CIDR Notation: A shorthand for representing subnet masks (e.g., /8, /16, /24).

6. Private IP Address Classes:

Private IP addresses are used within internal networks (like home, office, or enterprise LANs) and not routable on the public internet.


7. Loopback address:

A loopback address is a special IP address used to test and communicate with your own device (localhost). It doesn’t leave the device — it loops back internally.

  • 127.0.0.1 is the most commonly used loopback address.
  • The full range is from 127.0.0.0 to 127.255.255.255, but 127.0.0.1 is standard.
Example (Command Prompt):

If you get replies, your network stack is working.

8. Understanding Subnet Mask:

  • A subnet mask defines which part of the IP address is the network and which is the host.

  • Example:
    IP: 192.168.1.10
    Subnet Mask: 255.255.255.0
    ⇒ Network: 192.168.1 | Host: .10

9. CIDR:

9. 1 Full Form:

1. CIDR stands for Classless Inter-Domain Routing

9. 2 What It Means:

Classless: It doesn't follow the old Class A, B, C system of IP addressing.

Inter-Domain: It works between networks (domains) on the internet.

Routing: It improves the way IP addresses are grouped and routed.

9. 3 What is CIDR?

CIDR is a method for writing IP addresses and their subnet masks more efficiently.

 Instead of writing the subnet mask in full like this:

192.168.1.0 with subnet mask 255.255.255.0

You write it using CIDR notation:

192.168.1.0/24

9. 4 CIDR Format:

IP Address / Number of network bits

Example:

192.168.1.0/24

  • 192.168.1.0 → The network address

  • /24 → Tells us the first 24 bits are for the network
    (which equals 255.255.255.0)


10. Subnetting:

The formula used to calculate the number of usable IP addresses (or hosts) in a subnet:

2ⁿ - 2

n = number of bits available for the host portion

2ⁿ = total number of possible addresses

−2 = subtracting:

1 for the network address

1 for the broadcast address

Example:
Suppose we have a /24 subnet

That means 32 - 24 = 8 host bits

So:

2⁸ - 2 = 256 - 2 = 254 usable IP addresses

CIDR table:

CIDR

Subnet Mask

Total IPs

Usable IPs

/20

255.255.240.0

4096

4094

/21

255.255.248.0

2048

2046

/22

255.255.252.0

1024

1022

/23

255.255.254.0

512

510

/24

255.255.255.0

256

254

/25

255.255.255.128

128

126

/26

255.255.255.192

64

62

/27

255.255.255.224

32

30

/28

255.255.255.240

16

14

/29

255.255.255.248

8

6

/30

255.255.255.252

4

2


10.1 Scenario 1:

IP Block: 192.168.1.0/24 (Total 256 IPs: 254 usable)

Departments:

IT → Needs 50 IPs

HR → Needs 30 IPs

Finance → Needs 20 IPs

Step 1: List Requirements:


Department

Required IPs

Add Buffer

Closest Power of 2

Usable IPs

Needed CIDR

IT

50

+2

64 (2⁶)

62

/26

HR

30

+2

32 (2⁵)

30

/27

Finance

20

+2

32 (2⁵)

30

/27


(We add +2 to account for network + broadcast addresses.)

Step 2: Allocate Subnets:

Start from 192.168.1.0 and move up without overlaps.

🟦 Subnet 1: IT Department

  • Subnet: 192.168.1.0/26

  • Range:

    • Network: 192.168.1.0

    • Usable: 192.168.1.1 – 192.168.1.62

    • Broadcast: 192.168.1.63

🟨 Subnet 2: HR Department

  • Subnet: 192.168.1.64/27

  • Range:

    • Network: 192.168.1.64

    • Usable: 192.168.1.65 – 192.168.1.94

    • Broadcast: 192.168.1.95

🟩 Subnet 3: Finance Department

  • Subnet: 192.168.1.96/27

  • Range:

    • Network: 192.168.1.96

    • Usable: 192.168.1.97 – 192.168.1.126

    • Broadcast: 192.168.1.127

Final Subnet Summary

Department

Subnet

Usable IPs

Broadcast IP

IT

192.168.1.0/26

192.168.1.1–62

192.168.1.63

HR

192.168.1.64/27

192.168.1.65–94

192.168.1.95

Finance

192.168.1.96/27

192.168.1.97–126

192.168.1.127


IPs Remaining (Optional Use):

  • 192.168.1.128 – 192.168.1.255 (still unused)

  • You can use them for future expansion or guest VLANs, etc.

10.2 Scenario 2:

 Split 192.168.1.0/24 into 5 equal subnets

 Step 1: Base Network Info

  • Network: 192.168.1.0/24

  • Total IPs: 2⁸ = 256

  • We need: 5 equal subnets

Step 2: Formula for Number of Subnets

Formula:
2ˣ ≥ Number of Subnets Needed

Where:

  • x = number of bits borrowed from host portion

  • In /24, we have 8 host bits

  • We borrow 3 bits because:
    2³ = 8 ≥ 5 (this gives us 8 equal subnets)

 New CIDR = /24 + 3 = /27

Step 3: Subnet Size Calculation

Formula for total IPs per subnet:
2ⁿ
Where:

  • n = remaining host bits = 8 - 3 = 5

So:

  • 2⁵ = 32 IPs per subnet

  • Usable = 32 - 2 = 30 IPs (subtract network & broadcast)

Final Table – 5 Equal Subnets of /27

Subnet No.

Network Address

Usable IP Range

Broadcast Address

CIDR

Total IPs

Usable IPs

1

192.168.1.0

192.168.1.1 – 192.168.1.30

192.168.1.31

/27

32

30

2

192.168.1.32

192.168.1.33 – 192.168.1.62

192.168.1.63

/27

32

30

3

192.168.1.64

192.168.1.65 – 192.168.1.94

192.168.1.95

/27

32

30

4

192.168.1.96

192.168.1.97 – 192.168.1.126

192.168.1.127

/27

32

30

5

192.168.1.128

192.168.1.129 – 192.168.1.158

192.168.1.159

/27

32

30


Summary of Formulas Used:

Purpose

Formula

Example Used

No. of subnets needed

2^x ≥ required

2^3 = 8 ≥ 5

Total IPs per subnet

2^n

2^5 = 32

Usable IPs per subnet

2^n - 2

32 - 2 = 30

New subnet mask CIDR

/original + x

/24 + 3 = /27


Comments