IP Addressing
IPv4 Addressing
An IPv4 address is a 32-bit number written in dotted decimal notation — four octets (8-bit groups) separated by dots. Each octet ranges from 0 to 255.
Example: 192.168.1.100 = 11000000.10101000.00000001.01100100 in binary
IPv4 Address Classes
| Class | First Octet Range | Default Subnet Mask | Networks | Hosts/Network | Use |
|---|---|---|---|---|---|
| A | 1 – 126 | 255.0.0.0 (/8) | 126 | 16,777,214 | Large organizations |
| B | 128 – 191 | 255.255.0.0 (/16) | 16,384 | 65,534 | Medium organizations |
| C | 192 – 223 | 255.255.255.0 (/24) | 2,097,152 | 254 | Small organizations |
| D | 224 – 239 | N/A | N/A | N/A | Multicast |
| E | 240 – 255 | N/A | N/A | N/A | Reserved/Experimental |
Special IP Addresses
| Address/Range | Purpose |
|---|---|
| 127.0.0.0 – 127.255.255.255 | Loopback (localhost) — 127.0.0.1 is most common |
| 10.0.0.0 – 10.255.255.255 | Private Class A (RFC 1918) |
| 172.16.0.0 – 172.31.255.255 | Private Class B (RFC 1918) |
| 192.168.0.0 – 192.168.255.255 | Private Class C (RFC 1918) |
| 169.254.0.0 – 169.254.255.255 | APIPA (Automatic Private IP Addressing) — when DHCP fails |
| 0.0.0.0 | Default route / unspecified address |
| 255.255.255.255 | Limited broadcast (all hosts on local network) |
Unicast, Multicast, and Broadcast
- Unicast: One-to-one communication. A packet is sent from one source to one specific destination. Most common type.
- Broadcast: One-to-all communication. A packet is sent to all devices on a network. Example: 192.168.1.255 (directed broadcast for 192.168.1.0/24).
- Multicast: One-to-many communication. A packet is sent to a group of interested receivers. Uses Class D addresses (224.0.0.0 – 239.255.255.255).
- Anycast: One-to-nearest communication. A packet is sent to the nearest node in a group. Used in IPv6 and CDNs.
IPv6 Addressing
IPv6 uses 128-bit addresses written as 8 groups of 4 hexadecimal digits separated by colons.
Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Abbreviation rules:
- Leading zeros in each group can be omitted:
0db8→db8 - One consecutive group of all-zero groups can be replaced with
:::2001:db8::8a2e:370:7334
IPv4 vs IPv6
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address Size | 32 bits | 128 bits |
| Address Format | Dotted decimal (192.168.1.1) | Hexadecimal colon notation |
| Total Addresses | ~4.3 billion | ~340 undecillion |
| Header Size | 20-60 bytes (variable) | 40 bytes (fixed) |
| NAT Required | Yes (address exhaustion) | No (enough addresses) |
| Security | Optional (IPSec) | Built-in (IPSec mandatory) |
| Broadcast | Yes | No (uses multicast/anycast) |
| Auto-configuration | DHCP | SLAAC (Stateless Address Autoconfiguration) |
Ready to Level Up Your Skills?
Explore 500+ free tutorials across 20+ languages and frameworks.