IPv4 Addressing
An IPv4 address like 192.168.1.10 looks like four random numbers. It isn’t. In this lesson you learn to read it in binary, understand which part names the network and which names the device, and use a live subnet calculator. These skills are exactly what you need to design AWS VPCs.
In this session
- IPv4 = 32 bits in four octets (0–255)
- Binary ⇄ decimal with a live converter
- Special addresses: 0.0.0.0, 255.255.255.255, 127.0.0.1
- Which pairs of PCs can talk, and why
- Subnet masks, CIDR and a live subnet calculator
- AWS reserves 5 addresses per subnet
01What an IPv4 address looks like
02Binary ⇄ decimal: the easy trick
Each of the 8 positions has a value. Start at 1 and keep doubling: 128, 64, 32, 16, 8, 4, 2, 1. Add the values wherever the bit is 1. All eight 1s = 255.
| Binary | Working | Decimal |
|---|---|---|
| 10110001 | 128 + 32 + 16 + 1 | 177 |
| 11000000 | 128 + 64 | 192 |
| 10101000 | 128 + 32 + 8 | 168 |
| 00001010 | 8 + 2 | 10 |
| 11111111 | all of them | 255 |
11000000.03Special addresses
| Address | Name | Meaning |
|---|---|---|
0.0.0.0 | “any” address | “this device” or “all addresses”; never given to a PC. In AWS, 0.0.0.0/0 = anywhere on the internet |
255.255.255.255 | limited broadcast | a message to every device on the local network |
127.0.0.1 | loopback (localhost) | the computer talking to itself |
224–239.x.x.x | multicast | one-to-many groups |
240–255.x.x.x | reserved | research only |
So normal devices use first octets 1–223, except 127.
04Can these two PCs talk?
Two PCs on one cable can talk only if they are in the same network and have different, usable addresses. Here the network is 1.0.0.0 with mask 255.0.0.0:
1.0.5.0 is a valid device address; only 1.0.0.0 (all host bits 0) is the network ID.05Subnet mask and CIDR
An IP address has a fixed part (the network) and a changing part (the devices). The subnet mask marks them: 255 = network, 0 = device. CIDR is the short form: count the 1-bits in the mask.
| Subnet mask | CIDR | Network part | Addresses |
|---|---|---|---|
| 255.0.0.0 | /8 | first octet | 16,777,216 |
| 255.255.0.0 | /16 | first two octets | 65,536 |
| 255.255.255.0 | /24 | first three octets | 256 |
| 255.255.255.240 | /28 | 28 bits | 16 |
| 255.255.255.255 | /32 | all 32 bits | 1 (a single IP) |
| AWS reserves in every subnet | Example in 10.0.1.0/24 |
|---|---|
| Network address | 10.0.1.0 |
| VPC router | 10.0.1.1 |
| DNS server | 10.0.1.2 |
| Future use | 10.0.1.3 |
| Broadcast (not supported, still reserved) | 10.0.1.255 |
- A /24 subnet in AWS gives 251 usable IPs (256 − 5).
- VPC and subnet sizes in AWS: from /16 (65,536) to /28 (16).
/32= exactly one IP (e.g. “My IP” in a security group).0.0.0.0/0= everyone.
06Why IP addresses were divided up
If whole first-octet networks like 1.x.x.x (16.7 million addresses) were given to single companies, there would be room for only about 255 companies, and most addresses would be wasted. So IANA (which allocates addresses) and the IETF (which writes internet standards) divided addresses into classes of different sizes. That is Day 7.
07Summary
- IPv4 = 32 bits, four octets, each 0–255.
- Binary place values: 128 64 32 16 8 4 2 1; add where the bit is 1.
- First address = network ID, last = broadcast; neither goes to a device.
- Subnet mask: 255 = network, 0 = host; CIDR /n counts the network bits; addresses = 2^(32−n).
- AWS reserves 5 IPs per subnet: a /24 gives 251.
08Quick quiz
1. Convert 11000000 to decimal.
2. How many bits in an IPv4 address?
3. Can PC1 = 1.0.0.1 and PC2 = 1.0.0.0 communicate?
4. How many addresses in a /24?
5. Usable IPs in a /24 subnet in AWS?