Topic 1.1
IPv4 Addresses and Binary
In one line
An IPv4 address is 32 bits written as four decimal numbers (octets); understanding the binary underneath is what makes subnetting easy.
Think of it like this
A phone number with a country code, area code, and local number. The first part says which NETWORK, the last part which HOST on it. IP addresses work the same way, except the split point is flexible.
Key ideas
- 01
IPv4 addresses are 32 bits, written as four OCTETS (8 bits each) in decimal:
192.168.1.10. Each octet ranges from 0 to 255 (2^8 − 1). That gives ~4.3 billion addresses in total, which the internet ran out of years ago (hence NAT and IPv6). - 02
Binary refresher: each bit in an octet is worth 128, 64, 32, 16, 8, 4, 2, 1 from left to right.
192= 128 + 64 =11000000.168= 128 + 32 + 8 =10101000. You don't need to do this often, but seeing it once makes masks and CIDR obvious. - 03
Every address splits into a NETWORK portion (shared by every host on that network) and a HOST portion (unique per host). The SUBNET MASK marks the split:
255.255.255.0means the first 24 bits are network, the last 8 are hosts. - 04
Two addresses per subnet are reserved in traditional networking: the NETWORK address (all host bits 0, e.g.
192.168.1.0) and the BROADCAST address (all host bits 1, e.g.192.168.1.255). AWS reserves 5 per subnet (AWS course, Topic 3.1).
Code & diagrams
# Convert an IP to binary, octet by octet
for o in 192 168 1 10; do printf '%08d ' "$(echo "obase=2; $o" | bc)"; done; echo
# 11000000 10101000 00000001 00001010
# ipcalc shows network, broadcast, mask, host range
ipcalc 192.168.1.10/24Explain it without notes
Why is 255 the largest number in an IPv4 octet?
Practice
Convert 10.20.30.40 to binary. Which octet has the most 1 bits?
Trade-offs
- ↔
IPv4's 32-bit space is small, which forced NAT and private addressing. They keep the internet working but break end-to-end connectivity and complicate debugging.
Done when you can
I can convert an octet between decimal and binary.
I understand network vs host portions and what the subnet mask does.
I know the network and broadcast addresses of a subnet.