AWS Solutions Architect · Module 2 · Day 7

IP Classes, Public vs Private & DHCP

⏱ 14 min read🎯 Beginner friendly🖼 1 diagram🧪 2 live demos🐍 Python code

Yesterday you split an address into network and host parts. Today you see how the internet sized those parts into classes, which ranges are private (free, inside your network) and which are public (on the internet), and how devices get an address automatically with DHCP. Every idea here appears again in AWS VPCs.

In this session

  • Classes A, B, C, D and E by first octet
  • Counting networks and hosts per class
  • Public vs private IPs, and NAT
  • Loopback, APIPA and other special addresses
  • Static vs dynamic IPs, and how DHCP works (DORA)
  • Elastic IPs, NAT gateways and metadata in AWS

01The five classes

ClassFirst octetShapeDefault maskUsed for
A1 – 126N.H.H.H255.0.0.0 (/8)very large organisations
B128 – 191N.N.H.H255.255.0.0 (/16)medium / large companies
C192 – 223N.N.N.H255.255.255.0 (/24)small offices and homes
D224 – 239no splitnonemulticast
E240 – 255no splitnoneresearch

N = network octet (fixed), H = host octet (changes). 127 is missing on purpose: it is reserved for loopback.

🏘️

Buildings and flats. Class A = few buildings, each with millions of flats (huge organisations). Class C = many small buildings with 254 flats each (small offices).

Memory trick: classes start at 1, 128, 192, 224, 240.
Demo · Find the class and type of any IP

02Counting networks and hosts

ClassNetworksHowUsable hosts per network
A126first octet 1–12616,777,214 (256³ − 2)
B16,38464 first-octet values × 25665,534 (256² − 2)
C2,097,15232 × 256 × 256254 (256 − 2)

Class B check: 128.0.0.1 and 128.1.0.1 cannot talk directly. In Class B the first two octets are the network, so 128.0 and 128.1 are different networks.

03Public vs private IPs, and NAT

Public IPPrivate IP
Works onthe internetonly inside your network
Unique?unique worldwidecan repeat in different organisations
Costpaid (from an ISP or cloud provider)free
Example8.8.8.8 (Google DNS)192.168.1.10 (your laptop)
Private ranges (remember: 10, 172.16–31, 192.168)CIDR
10.0.0.0 – 10.255.255.25510.0.0.0/8
172.16.0.0 – 172.31.255.255172.16.0.0/12
192.168.0.0 – 192.168.255.255192.168.0.0/16
Laptop192.168.1.10 (private)Home routerNAT: swaps to public IPInternetsees 49.36.x.x (public)
NAT (Network Address Translation) lets many private devices share one public IP.
Note: a public IP has no “speed”. Speed comes from your ISP plan. A public IP simply makes you reachable on the internet.

04Special addresses

AddressWhat it means
127.0.0.1 (loopback, “localhost”)the computer talks to itself; ping 127.0.0.1 tests your TCP/IP software
169.254.x.x (APIPA / link-local)self-assigned when no DHCP server answers: a sign something is wrong
Network ID / broadcastfirst / last address of a network
0.0.0.0this device / any address
Windows Command Prompt
ipconfig          # your IP, mask and default gateway
ipconfig /all     # also shows the DHCP server
ping 127.0.0.1    # test your own TCP/IP software
ipconfig /release
ipconfig /renew   # give back the DHCP address and get a new one

05Static vs dynamic IPs, and DHCP

MethodHowGood for
Statictyped in by hand; never changesservers, printers, routers
Dynamicgiven automatically by a DHCP serverlaptops and phones
Demo · How DHCP gives you an address: DORA

06How AWS uses all this

IdeaIn AWS
Private rangesVPCs use them, e.g. 10.0.0.0/16 (size /16 to /28)
Public IPauto-assigned public IPs change on every stop/start
Static public IPElastic IP: stays the same until you release it
NATNAT Gateway lets private-subnet servers reach the internet without being reachable from it
DHCPevery EC2 instance gets its private IP from the VPC’s built-in DHCP
Link-local169.254.169.254 = instance metadata service (use IMDSv2)
🎯 Exam corner
  • Public IP must not change after stop/start → Elastic IP.
  • Private servers need updates but must not be reachable → NAT Gateway.
  • Since February 2024 every public IPv4 address is charged, so release unused Elastic IPs.

07Summary

08Quick quiz

1. 150.10.5.4 is in which class?

2. Is 172.20.5.9 public or private?

3. Your PC shows 169.254.33.7. It means…

4. DORA stands for…

5. EC2 public IP changed after stop/start. Fix?

09References

Created by Ajeetkumar