The Runtime Theory
Networking

IP Addresses, Subnets, and Routing

How IP addresses identify devices, how subnets divide networks into smaller segments, and how routers use routing tables to forward packets.

The Runtime Theory Team9 min read#ip#subnet#routing#cidr
▸ On this page

IP Addresses, Subnets, and Routing

IPv4 and IPv6

Every device on the internet has an IP address. IPv4 uses 32-bit addresses, written as four numbers separated by dots (e.g., 192.168.1.1). This gives about 4.3 billion addresses — enough for the early internet, but not enough today.

IPv6 uses 128-bit addresses, written as eight groups of hexadecimal digits separated by colons (e.g., 2001:db8::1). The double-colon :: is shorthand for consecutive zero groups, so 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1.

Subnets and CIDR Notation

A single IP network can be divided into smaller subnets. CIDR (Classless Inter-Domain Routing) notation expresses both the network and the subnet size: 192.168.1.0/24 means the network 192.168.1.0 with a 24-bit network prefix, leaving 8 bits for host addresses — that is, 256 possible addresses (254 usable, since the first is the network and the last is the broadcast).

NotationNetwork bitsHost bitsAddresses
/24248256
/25257128
/2626664
/16161665,536

Subnets let you divide a large network into smaller ones — e.g., one subnet per floor in an office building — reducing broadcast traffic and improving security.

How Routers Forward Packets

When a device wants to send a packet to another device, it checks whether the destination is on the same subnet. If so, it sends the packet directly (using the destination's MAC address via ARP).

If the destination is on a different subnet, the device sends the packet to its default gateway — a router. The router consults its routing table: a list of (destination network, next hop) pairs. It finds the entry that matches the destination IP and forwards the packet to the next hop. This process repeats at every router along the path.

On the internet, BGP (Border Gateway Protocol) is the routing protocol that connects autonomous systems (networks operated by different organizations). Each autonomous system announces which IP ranges it can reach, and BGP routers exchange these announcements to build a global routing table.

Private vs. Public Addresses

Some IP ranges are private (not routable on the internet) — used inside home and office networks:

RangeCIDR
10.0.0.0 – 10.255.255.25510.0.0.0/8
172.16.0.0 – 172.31.255.255172.16.0.0/12
192.168.0.0 – 192.168.255.255192.168.0.0/16

A NAT (Network Address Translation) router maps private addresses to a single public IP, allowing many devices to share one public address.

Next Steps

Learn about ports and sockets · See how DNS resolves names to addresses

Not started

Sign in to save your learning progress.

Sign in to save