☼
⌃
☰

IP Address

Table of Contents

A unique numerical label assigned to each device on a network using the Internet Protocol. Serves two purposes: host identification and location addressing. IPv4 is the dominant deployed protocol; IPv6 is the successor addressing the IPv4 exhaustion problem.

Related: CIDR Subnet Mask Static IP Dynamic IP

IPv4

32-bit addresses, written as four octets in dotted decimal: 192.168.1.100

Total address space: 2³² = ~4.3 billion addresses — exhausted in practice; NAT extends the life of the available space.

Reserved and Special Ranges

Range Purpose
10.0.0.0/8 Private (RFC 1918)
172.16.0.0/12 Private (RFC 1918)
192.168.0.0/16 Private (RFC 1918)
127.0.0.0/8 Loopback (localhost)
169.254.0.0/16 APIPA / link-local (no DHCP available)
224.0.0.0/4 Multicast
255.255.255.255 Broadcast (limited)
0.0.0.0 Unspecified / default route
169.254.169.254 Cloud metadata endpoint (AWS/Azure/GCP)

The cloud metadata IP (169.254.169.254) is worth knowing specifically — it is the SSRF target for credential theft in cloud environments.

CIDR — Classless Inter-Domain Routing

Replaces the old class-based system. An IP address and prefix length describe both the address and the network boundary: 192.168.1.0/24

The prefix length is the number of network bits; the remaining bits identify hosts within that network.

Prefix Subnet mask Hosts Typical use
/8 255.0.0.0 16,777,214 Large enterprise
/16 255.255.0.0 65,534 Medium org
/24 255.255.255.0 254 Small network / subnet
/25 255.255.255.128 126 Half subnet
/30 255.255.255.252 2 Point-to-point link
/32 255.255.255.255 1 Single host route

Quick subnet calculation

For a /24: last octet is the host part — hosts are .1 to .254, network address is .0, broadcast is .255.

For any prefix /N: 2(32-N) total addresses, minus 2 for network and broadcast = usable hosts.

PYTHON
import ipaddress

net = ipaddress.ip_network("192.168.1.0/24", strict=False)
print(net.network_address)   # 192.168.1.0
print(net.broadcast_address) # 192.168.1.255
print(net.num_addresses)     # 256
print(list(net.hosts())[:3]) # first 3 usable hosts

IPv6

128-bit addresses, written as eight groups of four hex digits separated by colons: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Abbreviation rules:

  • Leading zeros in a group can be omitted: 0db8 → db8
  • One consecutive run of all-zero groups can be replaced with ::

2001:db8::1 expands to 2001:0db8:0000:0000:0000:0000:0000:0001

Total address space: 2¹²⁸ — effectively inexhaustible.

Key IPv6 Address Types

Prefix Type Equivalent
::1/128 Loopback 127.0.0.1
fe80::/10 Link-local 169.254.x.x
fc00::/7 Unique local Private (RFC 1918)
2000::/3 Global unicast Public internet
ff00::/8 Multicast Multicast

Historical Class System (Obsolete)

Classful addressing was replaced by CIDR in 1993 but still appears in older documentation:

Class First octet Default mask Purpose
A 1–126 /8 Large networks
B 128–191 /16 Medium networks
C 192–223 /24 Small networks
D 224–239 N/A Multicast
E 240–255 N/A Experimental

127.x.x.x is reserved for loopback, hence Class A starts at 1.

Security Relevance

SHELL
# Identify your IP and subnet
ip a
ipconfig /all   # Windows

# Check whether an IP is private or public
python3 -c "import ipaddress; print(ipaddress.ip_address('10.0.0.1').is_private)"

# Subnet sweep (ping)
nmap -sn 192.168.1.0/24

# Quick subnet info
python3 -c "
import ipaddress
n = ipaddress.ip_network('10.10.10.0/24', strict=False)
print(f'Network: {n.network_address}')
print(f'Broadcast: {n.broadcast_address}')
print(f'Hosts: {n.num_addresses - 2}')
"
  • Private ranges (RFC 1918) are non-routable on the public internet — seeing them in traffic implies you're on a local network or looking at internal routing
  • APIPA addresses (169.254.x.x) indicate a host that failed to obtain a DHCP lease — worth noting during network triage
  • 169.254.169.254 is specifically the AWS/Azure/GCP metadata endpoint — critical SSRF target; see SSRF