Skip to main content

Networking Fundamentals

The one-sentence version

Network traffic is built in layers — each one wraps the one above it — and almost all troubleshooting is the act of working out which layer is broken.

The layer model

The OSI model has seven layers; in practice you reason about four.

OSINameCarriesYou debug it with
7ApplicationHTTP, DNS, SSHcurl, dig
4TransportTCP, UDP — portsss, nc, telnet
3NetworkIP — routingping, ip route, traceroute
2Data linkMAC, switchingip link, arp

The practical value is a debugging order. "The site is down" becomes a sequence: does the name resolve (7), does the port accept a connection (4), does the host answer at all (3)? Working bottom-up finds the real fault far faster than guessing.

TCP vs UDP

Both are layer 4. They make opposite tradeoffs.

TCPUDP
ConnectionThree-way handshakeNone
DeliveryGuaranteed, orderedBest effort
OverheadHigherMinimal
Used byHTTP, SSH, database protocolsDNS queries, streaming, VoIP

UDP is chosen when late data is worse than missing data. A dropped frame in a video call should be skipped, not retransmitted three seconds later.

DNS resolution

DNS turns a name into an address, and it is the first thing to suspect when something works by IP but not by hostname.

RecordMaps to
AIPv4 address
AAAAIPv6 address
CNAMEAnother name (never an IP)
MXMail servers
TXTArbitrary text — SPF, domain verification

TTL is the cache lifetime. It is why a DNS change is not instant, and why you drop TTL before a planned migration rather than during it.

HTTP status codes

The first digit is the whole story, and it tells you who is at fault.

ClassMeaningWhose problem
2xxSuccess
3xxRedirect
4xxClient errorThe request
5xxServer errorThe server

Worth knowing precisely: 401 means not authenticated, 403 means authenticated but not permitted, 502 means a gateway got a bad response from upstream, and 504 means upstream did not answer in time. In a load-balanced system, 502 and 504 usually point past the proxy to the backend.

Addressing

CIDR notation states how many leading bits are the network portion.

CIDRUsable hosts
/24254
/1665,534
/321 (a single host)

Two of the total are unusable: the network address and the broadcast address.

The RFC 1918 private ranges — 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 — are not routable on the public internet, which is why NAT exists: it translates many private addresses onto one public one on the way out.

Questions

Loading questions…

Learn more