ComparisonDifficulty: Intermediate2 min

IPv4 vs IPv6

IPv6 does not run out, needs no NAT for size, and is written in a way that looks nothing like IPv4.

IPv4 and IPv6 are two versions of the Internet Protocol that do the same job, addressing packets and carrying them between networks. IPv6 was designed because IPv4's 32-bit addresses ran out. Both run side by side on most networks today, and a device can have an address of each kind.

They differ on four things that change how you work with them: how many addresses there are, how they are written, how networks are divided, and whether NAT is needed.

IPv4 and IPv6 compared on the properties that matter when working with them
PropertyIPv4IPv6
Address size32 bits, about 4.3 billion128 bits, about 3.4 × 10^38
Written asFour decimal bytes: 192.0.2.10Eight groups of four hex digits: 2001:db8:0:0:0:0:0:10, shortened to 2001:db8::10
Typical subnetAny size, often /24/64 for every network, whatever its size
NATNeeded almost everywhere, for lack of addressesNot needed for lack of addresses
BroadcastYesNo; multicast to chosen groups instead
Finding a MAC addressARPNeighbour discovery
Private-use addressesThe three RFC 1918 rangesUnique local addresses, fc00::/7

The shorthand rules for writing IPv6 are short. Leading zeros in a group may be dropped, so 0db8 becomes db8, and one run of all-zero groups may be replaced by ::, once per address, so the reader can still work out how many groups were removed.

The difference that matters most is NAT. With 128-bit addresses there are enough for every device in the world to have its own globally reachable one, so IPv6 networks rarely need NAT. Without NAT, a firewall has to do the job of refusing unwanted incoming connections explicitly. IPv6 does still have private-use addresses, so their absence is not the reason NAT is rare.

The rule for choosing. You seldom choose one alone. Run both where you can, because many users and mobile networks now prefer IPv6, and keep IPv4 because a large part of the internet still needs it. Choose IPv6 as the only protocol for a network inside a large platform that has run short of private IPv4 space, and expect to keep a path to IPv4 at the edge for the services that still speak only that.