An IPv4 address is one 32-bit number
Every interface on an IP network — a laptop's Wi-Fi card, a router port, a printer — gets an address so packets know where to go. We write it as four decimal numbers, but the network only ever sees 32 ones and zeros.
Address decoder
Network part + host part
Think of a postal address. The network part is the street; every device on the same street shares it. The host part is the house number and must be unique on that street. The subnet mask (or /prefix) tells you where the street name ends.
How a device gets its address
An admin types the IP, mask, gateway and DNS by hand. Used for servers, routers and printers.
The device broadcasts a request and a DHCP server leases it an address (Discover → Offer → Request → Ack).
No DHCP reply? Windows and macOS self-assign 169.254.x.x. It only works on the local link — a sign something is wrong.
127.0.0.1 is always "this machine". It exists without any network card.
Public vs private, and why NAT exists
Hover the devicesThere are only about 4.3 billion IPv4 addresses and they ran out at IANA in February 2011. Homes and offices therefore use private ranges (10/8, 172.16/12, 192.168/16) that anyone may reuse. The router's NAT rewrites the private source address to its single public address on the way out, and remembers the mapping so replies find their way back.
IPv4 vs IPv6 at a glance
Flip the bits, watch the address change
Each octet is 8 switches worth 128, 64, 32, 16, 8, 4, 2 and 1. Turn a switch on and its value is added. Click any bit below, or type an address.
Bit flipper
Decimal → binary, step by step
The subtraction method: walk the place values from 128 down. If it fits, write 1 and subtract; if not, write 0.
Target challenge
Match the numberSwitch bits on until the octet equals the target. Try to beat your streak.
The nine mask octets
A subnet mask is a run of 1s followed by 0s, so each mask octet can only be one of these nine values. Memorise them and subnetting gets fast.
Powers of two
Block sizes and host counts are always powers of two. Usable hosts = 2host bits − 2 (network and broadcast addresses are reserved).
Which kind of address is it?
Before 1993 the first few bits of an address fixed its class and its network size. Classes are history on the real Internet (CIDR replaced them), but they still explain default masks and appear in every networking exam. Special ranges — private, loopback, multicast — matter every day.
Address inspector
The five classes
Map of all 256 “/8” blocks
Each square is a first octet · click oneSpecial-purpose addresses
IANA special-purpose registry (RFC 6890) and friendsWhere the network ends and the host begins
A subnet mask is 32 bits: a run of 1s marks the network part, the 0s that follow mark the host part. CIDR notation just counts the 1s — 255.255.255.0 is /24.
Slide the prefix
Subnet calculator
The magic-number shortcut
Follows the calculatorCan these two talk directly?
Hosts on the same subnet deliver frames to each other directly (after ARP). Otherwise traffic must go through a router.
Subnetting is borrowing host bits
To cut one network into smaller ones, you move the mask to the right. Every bit you borrow from the host part doubles the number of subnets and halves the size of each.
Borrow bits
Visual splitter
Divide and join blocks · name themVLSM planner
Variable-length masks: right-size every subnetInside an IPv4 packet
Every packet starts with a header of at least 20 bytes — the envelope routers read to forward it. Click a field to learn what it does, edit the values, and watch the checksum and raw bytes update.
Header builder
How the checksum is calculated
TTL: why packets don't loop forever
Each router subtracts 1 from TTL. When it reaches 0 the router drops the packet and sends back ICMP “Time Exceeded”. Traceroute uses exactly this trick with TTL = 1, 2, 3…
Fragmentation
When a packet is bigger than the link MTUOffsets count in 8-byte units, so every fragment except the last carries a multiple of 8 data bytes. The receiver — never a router — reassembles using the shared Identification value.
The protocols that make IPv4 work
IP only moves packets between addresses. Other protocols find MAC addresses (ARP), hand out addresses (DHCP), turn names into addresses (DNS), report problems (ICMP) and carry application data (TCP and UDP). Pick one and step through it message by message.
Protocol player
Encapsulation: how data goes down and up the stack
Unicast, broadcast, multicast, anycast
Routing: longest prefix wins
A router compares the destination with every route. Of all matches, it picks the one with the longest prefix (most specific). The default route 0.0.0.0/0 matches everything and is the last resort.
Routing protocols compared
Administrative distance (Cisco defaults) decides which source to trust when two protocols know a route to the same prefix — lower wins. Directly connected = 0, static = 1.
Build, break and fix a small network
Two LANs, a router with NAT and DHCP, and the Internet. Click any device to change its address, mask or gateway, then ping or traceroute and watch every ARP, ICMP and DHCP message cross the wires.
Try these
- Select PC2 and press Get address (DHCP) — watch Discover, Offer, Request, Ack.
- Ping PC1 → Server: ARP for the gateway, then the router ARPs on LAN B.
- Ping the same target again — no ARP this time, the caches remember.
- Traceroute PC1 → 198.51.100.20 to see every hop and the NAT table fill.
Break it on purpose
- Load Wrong gateway: PC3 can reach its neighbours but nothing beyond.
- Load Wrong mask: PC1 thinks LAN B is local and ARPs into the void.
- Load Duplicate IP: two ARP replies for one address.
- Turn NAT off on R1 and ping the Internet.
Reading the log
Every line is one message on a wire. Frames carry MAC addresses and change at every hop; packets carry IP addresses end to end — except where NAT rewrites them.
Switches learn which MAC lives on which port (click a switch to see its table). Routers decrement TTL and pick the longest matching route.
Everyday IPv4 calculators
Convert between notations, turn an arbitrary range into CIDR blocks, summarise routes, and work out wildcard masks for ACLs and OSPF.
Any-format converter
Range → CIDR blocks
Firewalls and routers want prefixes, not ranges. This finds the fewest CIDR blocks that cover a range exactly.
Route summarisation
Advertise one route instead of many. The summary keeps the bits all networks share.
Wildcard masks & ACLs
Cisco ACLs and OSPF use wildcard masks: 0 = must match, 1 = don't care. For a subnet it is simply the inverted mask.
Practise until it's automatic
Questions are generated fresh every time, so you can keep going. Each answer comes with the working, so a wrong answer is still a lesson.
By topic
Cheat sheets
Everything worth keeping at hand: the full CIDR table, common ports, IP protocol numbers, ICMP types and a glossary.
CIDR table
The rows you will use most are highlightedCommon ports
IP protocol numbers
The value in the IPv4 header's Protocol field.