← Back to Networking

DHCP, NAT, IPv6, and ICMP

Hosts need addresses automatically, private networks share public addresses, IPv6 provides vastly more addresses, and ICMP reports problems. These are the network layer's supporting cast.

DHCP

The Dynamic Host Configuration Protocol (DHCP) gives a joining host an IP address, subnet mask, default gateway (first-hop router), and DNS server addresses, usually as a lease for a set time. The exchange has four steps, often remembered as DORA: Discover (broadcast), Offer, Request, and Acknowledge. DHCP runs over UDP and is how laptops get addresses on Wi-Fi.

Private addresses

Three IPv4 ranges are reserved for private use: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They can be reused in any number of homes and offices but are not routed on the public internet. Addresses such as 192.168.1.20 are therefore extremely common inside home networks.

Network address translation

A NAT router lets many private-address hosts share one public address. For each outgoing connection, it rewrites the source address and port to its public address and a chosen port, recording the mapping in a translation table; replies are rewritten back. NAT extended IPv4's life enormously but breaks the end-to-end model, complicating incoming connections, peer-to-peer applications, and some protocols.

Carrier-grade NAT

As IPv4 addresses ran out, many ISPs, especially mobile operators, began using carrier-grade NAT, placing customers behind shared public addresses at the ISP level, sometimes in addition to NAT in the home. This saves addresses but makes customers' devices unreachable from outside and complicates logging and troubleshooting.

IPv6

IPv6, standardised in the 1990s and updated as RFC 8200 in 2017, uses 128-bit addresses written as eight groups of four hexadecimal digits, with leading zeros and one run of zero groups shortened, as in 2001:db8::1. Its fixed 40-byte header drops the checksum and router fragmentation, and adds a flow label. Hosts can configure their own addresses with stateless address autoconfiguration (SLAAC).

Transition to IPv6

IPv4 and IPv6 are not directly compatible, so the transition runs for decades. Dual-stack hosts and routers run both. Tunnelling carries IPv6 inside IPv4 across older networks. Translation mechanisms such as NAT64 let IPv6-only clients reach IPv4 servers. Google's measurements show that around half of its users reached it over IPv6 by the mid-2020s, with large differences between countries.

ICMP

The Internet Control Message Protocol (ICMP) carries error and diagnostic messages: destination unreachable, time exceeded (TTL reached zero), packet too big (used in path MTU discovery), and echo request and reply, used by ping. Traceroute relies on time-exceeded messages from successive routers. ICMPv6 additionally handles neighbour discovery, replacing ARP in IPv6.

Worked example

A laptop with private address 192.168.1.20 opens a connection from port 52000 to a web server. The home router with public address 203.0.113.5 rewrites the source to 203.0.113.5 port 40001 and records 40001 -> 192.168.1.20:52000. The server replies to 203.0.113.5:40001; the router looks up the entry and forwards the reply to 192.168.1.20:52000. A second laptop gets a different public port, so both share one address.

Key takeaways

DHCP's discover, offer, request, acknowledge exchange gives hosts an address, mask, gateway, and DNS servers on lease. Private ranges 10/8, 172.16/12, and 192.168/16 are reused freely but not routed publicly. NAT shares one public address by rewriting addresses and ports, at the cost of end-to-end reachability; carrier-grade NAT does this at ISP scale. IPv6 (RFC 8200) has 128-bit addresses, a simpler 40-byte header, and SLAAC. Transition uses dual stack, tunnelling, and NAT64; about half of Google's users used IPv6 by the mid-2020s. ICMP reports errors and supports ping and traceroute.

Flashcard

DHCP

Assigns addresses and settings automatically

Lease.

Check your understanding

Why can't an outside computer usually start a connection to a laptop behind a home NAT router?

← Previous lesson Next lesson →