IP Classes, Public vs Private & DHCP
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
| Class | First octet | Shape | Default mask | Used for |
|---|---|---|---|---|
| A | 1 – 126 | N.H.H.H | 255.0.0.0 (/8) | very large organisations |
| B | 128 – 191 | N.N.H.H | 255.255.0.0 (/16) | medium / large companies |
| C | 192 – 223 | N.N.N.H | 255.255.255.0 (/24) | small offices and homes |
| D | 224 – 239 | no split | none | multicast |
| E | 240 – 255 | no split | none | research |
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).
02Counting networks and hosts
| Class | Networks | How | Usable hosts per network |
|---|---|---|---|
| A | 126 | first octet 1–126 | 16,777,214 (256³ − 2) |
| B | 16,384 | 64 first-octet values × 256 | 65,534 (256² − 2) |
| C | 2,097,152 | 32 × 256 × 256 | 254 (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 IP | Private IP | |
|---|---|---|
| Works on | the internet | only inside your network |
| Unique? | unique worldwide | can repeat in different organisations |
| Cost | paid (from an ISP or cloud provider) | free |
| Example | 8.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.255 | 10.0.0.0/8 |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 |
04Special addresses
| Address | What 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 / broadcast | first / last address of a network |
0.0.0.0 | this device / any address |
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
| Method | How | Good for |
|---|---|---|
| Static | typed in by hand; never changes | servers, printers, routers |
| Dynamic | given automatically by a DHCP server | laptops and phones |
06How AWS uses all this
| Idea | In AWS |
|---|---|
| Private ranges | VPCs use them, e.g. 10.0.0.0/16 (size /16 to /28) |
| Public IP | auto-assigned public IPs change on every stop/start |
| Static public IP | Elastic IP: stays the same until you release it |
| NAT | NAT Gateway lets private-subnet servers reach the internet without being reachable from it |
| DHCP | every EC2 instance gets its private IP from the VPC’s built-in DHCP |
| Link-local | 169.254.169.254 = instance metadata service (use IMDSv2) |
- 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
- Classes by first octet: A 1–126, B 128–191, C 192–223, D multicast, E research.
- Usable hosts: A 16,777,214 · B 65,534 · C 254.
- Private ranges: 10/8, 172.16/12, 192.168/16; NAT shares one public IP.
- 127.x = loopback; 169.254.x = APIPA (no DHCP).
- DHCP = automatic IPs via DORA; AWS: Elastic IP, NAT Gateway, VPC DHCP.
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?