IP Addressing
IP (Internet Protocol) addresses are unique numerical identifiers assigned to every device on a network. IPv4 uses 32-bit addresses; IPv6 uses 128-bit addresses.
IPv4 Address Structure
Example: 192.168.1.100
Octet 1
11000000
Octet 2
10101000
Octet 3
00000001
Octet 4
01100100
32 bits total = 4 octets × 8 bits each
Network Address
Identifies the network. All host bits = 0.
192.168.1.0Host Address
Identifies a specific device on the network.
192.168.1.100Broadcast
Sends to all hosts on the network. All host bits = 1.
192.168.1.255IPv4 Address Classes
| Class | Range | Default Mask | Usable Hosts | Network/Host Bits | Use Case |
|---|---|---|---|---|---|
| A | 1.0.0.0 – 126.255.255.255 | 255.0.0.0 | 16,777,214 | 8 net / 24 host | Large networks (ISPs, enterprises) |
| B | 128.0.0.0 – 191.255.255.255 | 255.255.0.0 | 65,534 | 16 net / 16 host | Medium networks (universities) |
| C | 192.0.0.0 – 223.255.255.255 | 255.255.255.0 | 254 | 24 net / 8 host | Small networks (homes, offices) |
| D | 224.0.0.0 – 239.255.255.255 | N/A | N/A | Multicast | Multicast groups |
| E | 240.0.0.0 – 255.255.255.255 | N/A | N/A | Reserved | Research/experimental |
Private IP Ranges (RFC 1918)
These ranges are reserved for private networks and are not routable on the public internet.
Class A
10.0.0.0/8
10.0.0.0 – 10.255.255.255
16,777,216 addresses
Class B
172.16.0.0/12
172.16.0.0 – 172.31.255.255
1,048,576 addresses
Class C
192.168.0.0/16
192.168.0.0 – 192.168.255.255
65,536 addresses
IPv4 vs IPv6
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address length | 32 bits | 128 bits |
| Format | Dotted decimal (192.168.1.1) | Hexadecimal (2001:db8::1) |
| Total addresses | ~4.3 billion | ~340 undecillion |
| Header size | 20–60 bytes | 40 bytes (fixed) |
| NAT required | Yes (address exhaustion) | No (enough addresses) |
| Security | Optional (IPSec) | Built-in IPSec |
| Broadcast | Yes | No (uses multicast) |
| Auto-configuration | DHCP required | SLAAC (stateless) |
Interview Questions
Q: What is the difference between public and private IP?
Public IPs are globally unique and routable on the internet. Private IPs (RFC 1918) are used within local networks and require NAT to access the internet.
Q: What is a loopback address?
127.0.0.1 (IPv4) or ::1 (IPv6) — used to test the network stack on the local machine without sending packets over the network.
Q: Why is IPv6 needed?
IPv4 has only ~4.3 billion addresses, which are exhausted. IPv6 provides 340 undecillion addresses to support the growing internet.
Q: What is APIPA?
Automatic Private IP Addressing (169.254.0.0/16) — assigned when a DHCP server is unavailable.