Opscraft
IP addressing & subnetting · Lesson 1 of 9 · 3 min read

IPv4 structure and binary

IP addressing questions are quick arithmetic once you can see addresses in binary, remember the class and private ranges, and use the block-size trick. Interviewers use them as a fundamentals check ("how many usable hosts in a /27?", "is this address in that subnet?"), and in AWS the same maths decides how you size VPCs and subnets — which matters a lot on EKS, where every pod consumes a VPC IP. This topic takes you from binary basics to planning IP space for a multi-account AWS organisation.

The address

An IPv4 address is 32 bits, written as four octets (8 bits each) in dotted decimal: 192.168.10.77. Each octet ranges from 0 to 255. Total address space: 2³² ≈ 4.29 billion addresses — not enough for the modern internet, hence NAT, private ranges and IPv6.

Binary conversion

Each bit in an octet has a place value:

Bit 128 64 32 16 8 4 2 1

To convert decimal → binary, subtract place values from the left:

  • 192 = 128 + 64 → 11000000
  • 168 = 128 + 32 + 8 → 10101000
  • 10 = 8 + 2 → 00001010
  • 77 = 64 + 8 + 4 + 1 → 01001101
  • 255 → 11111111; 0 → 00000000

So 192.168.10.77 = 11000000.10101000.00001010.01001101.

Enlarge diagram128064132016081412011place valuebit for 7764 + 8 + 4 + 1 = 77 → 01001101
Figure 1. Converting one octet to binary: each bit has a place value, and the 1-bits add up to the number. 77 = 64 + 8 + 4 + 1.
Swipe sideways to see all of it, or tap to open it full screen.

Memorise the mask-octet values — sums of leading 1-bits:

Bits set 1 2 3 4 5 6 7 8
Octet value 128 192 224 240 248 252 254 255

Network part and host part

A subnet mask (or prefix length) splits the address into:

  • the network portion — identifies the subnet (all hosts in a subnet share it);
  • the host portion — identifies the device within the subnet.

192.168.10.77/24 → mask 255.255.255.0 → network 192.168.10.0, host .77.

Computing the network address is a bitwise AND of the address and mask:

Enlarge diagramnetwork part: 27 bits, shared by the whole subnethost part: 5 bits19216810775 host bits = 2⁵ = 32 addresses, 30 usable · mask 255.255.255.224
Figure 2. A prefix length splits the 32 bits into a network part and a host part. With /27, the first 27 bits name the subnet and the last 5 number the hosts.
Swipe sideways to see all of it, or tap to open it full screen.
address  11000000.10101000.00001010.01001101   192.168.10.77
mask     11111111.11111111.11111111.11100000   255.255.255.224 (/27)
AND      11000000.10101000.00001010.01000000   192.168.10.64  ← network

Two hosts can talk directly (without a router) only if they're in the same subnet — same network portion under the mask. Otherwise traffic goes through the default gateway, which itself must be inside the host's subnet.