Computer Networking Cheatsheet

IP Addressing

Use this Computer Networking reference while you build software engineering projects, review code, or refresh the syntax you reach for most.

Anatomy of an IPv4 address

32 bits written as four dotted decimal octets, each 0-255. A mask splits it into a network part and a host part.

  192   .   168   .    10   .    37
11000000.10101000.00001010.00100101   address  192.168.10.37
11111111.11111111.11111111.00000000   mask     255.255.255.0  (/24)
11000000.10101000.00001010.00000000   network  192.168.10.0
11000000.10101000.00001010.11111111   broadcast 192.168.10.255

Rules that always hold in IPv4: the all-zeros host is the network address, the all-ones host is the broadcast address, and neither is assignable. A /24 therefore has 256 addresses but only 254 usable hosts.

Legacy classes

Classful addressing is obsolete (CIDR replaced it in 1993) but the vocabulary survives in exams, docs, and tool defaults.

ClassFirst octetDefault maskNetworksHosts per network
A1-126/8 255.0.0.012616,777,214
B128-191/16 255.255.0.016,38465,534
C192-223/24 255.255.255.02,097,152254
D224-239none (multicast)——
E240-255none (reserved)——

127.0.0.0/8 is carved out of class A for loopback, which is why class A stops at 126.

Private ranges (RFC 1918) and other reserved blocks

Private addresses are not routable on the public internet, so they must be translated by NAT to reach it.

BlockCIDRAddressesNotes
10.0.0.0-10.255.255.25510.0.0.0/816,777,216RFC 1918, big flat enterprise space
172.16.0.0-172.31.255.255172.16.0.0/121,048,576RFC 1918, Docker default neighborhood
192.168.0.0-192.168.255.255192.168.0.0/1665,536RFC 1918, home routers
127.0.0.0/8loopback16,777,216127.0.0.1 localhost
169.254.0.0/16link-local65,536APIPA, DHCP failed · cloud metadata 169.254.169.254
100.64.0.0/10CGNAT4,194,304RFC 6598, carrier-grade NAT, Tailscale
0.0.0.0/8this network—0.0.0.0 means "any" when binding
224.0.0.0/4multicast—groups, not hosts
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24documentation768RFC 5737, safe in examples

A common interview trap: 172.32.0.0 is public, because the private range stops at 172.31.255.255.

Loopback and 0.0.0.0 when binding

Which address a server binds decides who can reach it, and this is the single most common "works locally, not from another machine" bug.

Bind addressReachable fromUse when
127.0.0.1only the same hostdev servers, DB behind a proxy
0.0.0.0every IPv4 interfacecontainers, LAN services
::every IPv6 interface, often IPv4 too via dual stackmodern servers
a specific IPonly that interfacemulti-homed hosts, split traffic
ss -lntp                    # listening TCP sockets with the owning process
ss -lntp 'sport = :8080'    # who holds a port

Public IP, ASNs, and who owns a prefix

Public space is delegated by IANA to five RIRs (ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC) which assign it to organizations, each identified by an autonomous system number.

curl -s https://ifconfig.me                  # your egress public IP
dig +short myip.opendns.com @resolver1.opendns.com
whois 8.8.8.8 | grep -iE 'orgname|netname|cidr'
whois -h whois.cymru.com " -v 8.8.8.8"       # ASN, prefix, country

Your egress IP is not your interface IP when NAT is in the path, and both differ from the address a load balancer or CDN shows the origin. That is what X-Forwarded-For exists to carry.