Skip to content

Lesson 1 of 3

IP addresses and subnets

2 min

An IPv4 address is 32 bits, written as four numbers from 0 to 255: 192.168.1.20.

Network and host

Part of the address identifies the network, and the rest identifies the host (the device) on it. CIDR notation says how many bits belong to the network:

  • 192.168.1.0/24: the first 24 bits are the network, leaving 8 bits for hosts.
  • 8 host bits = 2^8 = 256 addresses.
  • The first is the network address and the last is the broadcast address, so 254 are usable.

Quick reference

  • /24: 256 addresses, 254 usable
  • /27: 32 addresses, 30 usable
  • /29: 8 addresses, 6 usable
  • /30: 4 addresses, 2 usable (point-to-point links)

The formula: usable hosts = 2^(32 − prefix) − 2.

Private ranges

These ranges are reserved for internal networks and never routed on the public internet:

10.0.0.0/8
172.16.0.0/12
192.168.0.0/16

Your router uses NAT (Network Address Translation) to let many private devices share one public IP.

IPv6

IPv6 addresses are 128 bits, written in hex: 2001:db8::1. There are so many that NAT is rarely needed, and a single /64 subnet holds more addresses than the whole IPv4 internet.