Networking Cheat Sheet for Developers and CS Students
β‘ Quick Answer
A practical networking cheat sheet β OSI and TCP/IP layers, ports, TCP vs UDP vs QUIC, DNS resolution, TLS, CIDR and NAT, plus the diagnostic command sequence.
Get more content like this on Telegram!
Daily AI tips, notes & resources β free
Advertisement
Networking Cheat Sheet for Developers
Most application bugs that look like networking bugs are one of four things: DNS returning the wrong address, a firewall dropping a port, TLS failing to negotiate, or nothing listening on the other end.
This sheet gives you the model to reason about that, the tables you look up, and the command sequence that isolates the layer.
Updated for 2026. Covers IPv4/IPv6, HTTP/3 and TLS 1.3.
OSI vs TCP/IP
| OSI layer | Name | TCP/IP layer | Example |
|---|---|---|---|
| 7 | Application | Application | HTTP, DNS, SMTP |
| 6 | Presentation | Application | TLS, encoding |
| 5 | Session | Application | Session management |
| 4 | Transport | Transport | TCP, UDP, QUIC |
| 3 | Network | Internet | IP, ICMP, routing |
| 2 | Data Link | Link | Ethernet, ARP, MAC |
| 1 | Physical | Link | Cables, Wi-Fi radio |
OSI is the vocabulary; TCP/IP is the machine. The internet was built first and modelled afterwards. Interviews ask for seven layers; debugging uses four.
The postal analogy holds well. Layer 7 is the letter you wrote. Layer 4 is whether you paid for tracked delivery. Layer 3 is the address on the envelope. Layer 2 is the van between two sorting offices.
What each layer actually does:
- Link moves a frame between two devices on the same physical segment, addressed by MAC address. ARP is how an IP address is translated to a MAC on a local network.
- Internet moves a packet across networks by IP address, hop by hop, with no guarantee it arrives.
- Transport adds ports, so one machine can run many services, and β if you chose TCP β reliability on top of an unreliable layer below.
- Application is your protocol: HTTP, DNS, SMTP.
Layer 3 does not guarantee delivery. Layer 4 is where reliability is invented. That single sentence explains why TCP exists.
Ports You Should Recognise
| Port | Protocol | Notes |
|---|---|---|
| 20 / 21 | FTP | Data / control |
| 22 | SSH | Also SFTP and scp |
| 25 | SMTP | Mail transfer; often blocked outbound |
| 53 | DNS | UDP normally, TCP for large responses |
| 67 / 68 | DHCP | Address assignment |
| 80 | HTTP | |
| 110 / 143 | POP3 / IMAP | Mail retrieval |
| 443 | HTTPS | Also QUIC / HTTP/3 over UDP |
| 3306 | MySQL | |
| 5432 | PostgreSQL | |
| 6379 | Redis | |
| 27017 | MongoDB |
Ports 0β1023 are well-known and on Unix require root to bind β the historical reason apps run on 3000 or 8080 in development.
Never expose 3306, 5432, 6379 or 27017 to the internet. Redis and MongoDB in particular have been mass-compromised because of default configurations reachable from anywhere.
TCP vs UDP vs QUIC
| TCP | UDP | QUIC | |
|---|---|---|---|
| Connection | Yes, 3-way handshake | None | Yes, over UDP |
| Reliable | Yes | No | Yes |
| Ordered | Yes | No | Per stream |
| Setup cost | 1 RTT (+1 for TLS 1.3) | 0 | 1 RTT, or 0 on resume |
| Head-of-line blocking | Yes, whole connection | N/A | Only within one stream |
| Encryption | Optional (TLS on top) | Optional | Built in, always |
| Used by | HTTP/1.1, HTTP/2, SSH | DNS, VoIP, games | HTTP/3 |
TCP when every byte must arrive. Web pages, APIs, file transfer, databases.
UDP when late data is worthless. In a voice call, a packet that arrives 400 ms late is not useful β retransmitting it makes the call worse, not better.
QUIC exists to fix one specific TCP flaw. In HTTP/2 over TCP, many streams share one connection, so a single lost packet stalls all of them until it is retransmitted. QUIC runs its own streams over UDP, so loss only stalls the stream that lost a packet.
The TCP handshake
Client Server
|------------ SYN ------------>| "let's talk, my seq = x"
|<-------- SYN + ACK ----------| "ok, my seq = y, I got x"
|------------ ACK ------------>| "I got y"
|======= connection open ======|Three messages, one full round trip, before a single byte of your data moves. On a 200 ms link that is 200 ms of latency you cannot optimise away β which is why connection reuse and keep-alive matter so much.
Closing takes four messages (FIN, ACK, FIN, ACK), and the initiator sits in TIME_WAIT afterwards. Thousands of sockets in TIME_WAIT on a busy server is normal, not a leak.
DNS
| Record | Maps to | Typical use |
|---|---|---|
A | IPv4 address | Point a name at a server |
AAAA | IPv6 address | Same, over IPv6 |
CNAME | Another name | Alias; cannot coexist with other records at the same name |
MX | Mail server + priority | Email delivery |
TXT | Arbitrary text | SPF, DKIM, domain verification |
NS | Authoritative name servers | Delegation |
SOA | Zone metadata | Serial, refresh, negative TTL |
PTR | Name from an IP | Reverse lookup |
SRV | Host + port for a service | SIP, XMPP, internal discovery |
CAA | Permitted certificate authorities | Restricts who may issue TLS certs |
A resolution walkthrough
Requesting www.example.com:
- Browser and OS cache are checked, then
/etc/hosts. - The query goes to your configured recursive resolver (your ISP, or a public one like
1.1.1.1). - If uncached, the resolver asks a root server. Root does not know the answer; it returns the name servers for
com. - The resolver asks a
comTLD server, which returns the authoritative name servers forexample.com. - The resolver asks one of those authoritative servers, which returns the
Arecord. - The resolver caches it for its TTL and answers you.
This is why DNS changes appear at different times for different people. Every resolver in the chain holds its own cached copy until its TTL expires. Lower the TTL before a migration, not during it.
CNAME cannot coexist with other records at the same name, which is why a root domain usually cannot be a CNAME β providers offer ALIAS or ANAME as a workaround.
HTTP Versions
| HTTP/1.1 | HTTP/2 | HTTP/3 | |
|---|---|---|---|
| Transport | TCP | TCP | QUIC over UDP |
| Multiplexing | No β one request at a time per connection | Yes, many streams | Yes, many streams |
| Head-of-line blocking | At HTTP level | At TCP level | Eliminated |
| Headers | Plain text | Binary, HPACK compressed | Binary, QPACK compressed |
| Encryption | Optional | Effectively required by browsers | Always |
| Connection setup | TCP + TLS | TCP + TLS | 1 RTT, 0-RTT on resume |
HTTP/1.1's limitation drove a decade of workarounds β sprite sheets, file concatenation, domain sharding β all to work around six connections per host. HTTP/2 multiplexing made most of them counterproductive.
HTTP/2 moved the blocking problem, it did not remove it. Streams no longer block each other at the HTTP layer, but they still share one TCP connection, so one lost packet stalls everything. HTTP/3 solves this by leaving TCP entirely.
TLS
A TLS 1.3 handshake in outline:
- ClientHello β supported versions and ciphers, plus a key share guess.
- ServerHello β chosen cipher, its key share, and the certificate chain.
- Both sides derive the same session key from their key shares; the client verifies the certificate against its trusted root store.
- Encrypted application data flows.
TLS 1.3 completes in one round trip, down from two in TLS 1.2, and drops every cipher suite without forward secrecy. A resumed session can send data in zero round trips.
Common failures and what they actually mean:
| Error | Cause |
|---|---|
certificate has expired | Renewal did not run |
hostname mismatch | The name you requested is not in the certificate's SAN list |
unable to get local issuer certificate | Intermediate certificate not served β works in browsers, fails in curl |
handshake failure | No cipher or protocol version in common |
The intermediate-certificate case is the sneaky one. Browsers often cache intermediates from previous sites and appear fine, while curl, mobile apps, and server-to-server calls fail. Always test with openssl s_client, not just a browser.
IP Addresses and CIDR
Private ranges (never routed on the internet):
| Range | CIDR | Addresses |
|---|---|---|
10.0.0.0 β 10.255.255.255 | 10.0.0.0/8 | ~16.7 million |
172.16.0.0 β 172.31.255.255 | 172.16.0.0/12 | ~1 million |
192.168.0.0 β 192.168.255.255 | 192.168.0.0/16 | 65,536 |
Also reserved: 127.0.0.0/8 (loopback), 169.254.0.0/16 (link-local, meaning DHCP failed).
CIDR notation states how many leading bits are the network:
| CIDR | Subnet mask | Usable hosts |
|---|---|---|
/24 | 255.255.255.0 | 254 |
/25 | 255.255.255.128 | 126 |
/26 | 255.255.255.192 | 62 |
/28 | 255.255.255.240 | 14 |
/30 | 255.255.255.252 | 2 |
/32 | 255.255.255.255 | 1 β a single host |
The arithmetic: host bits = 32 - prefix; usable hosts = 2^hostbits - 2. Two are subtracted for the network address and the broadcast address.
/32 means exactly one address and 0.0.0.0/0 means everything β the two you meet most in firewall rules and security groups.
NAT is why private addresses work. Your router rewrites the private source address of outgoing packets to its one public address, records the mapping, and reverses it on the reply. Fifty devices, one public IP.
The side effect: nothing outside can initiate a connection inward without an explicit port forward. That is a large part of why home networks are accidentally secure.
Load Balancer vs Reverse Proxy vs CDN
| Reverse proxy | Load balancer | CDN | |
|---|---|---|---|
| Primary job | Front one or more backends | Distribute across identical backends | Serve cached copies near the user |
| Health checks | Optional | Core feature | Of origin |
| Geographic | Single location | Usually single region | Globally distributed |
| Solves | TLS termination, routing, auth | Capacity and failover | Latency and origin load |
| Examples | Nginx, Caddy | HAProxy, AWS ALB | Cloudflare, Fastly |
Every load balancer is a reverse proxy; not every reverse proxy is a load balancer. A CDN is a globally distributed cache that usually also acts as both.
Layer 4 versus layer 7 balancing: L4 forwards TCP connections without reading them β fast, protocol-agnostic, no routing by path. L7 parses HTTP, so it can route /api and /static to different pools, but must terminate TLS to do so.
The Diagnostic Sequence
When something cannot connect, go up the stack in order. Each step eliminates a class of cause.
# 1. DNS β does the name resolve, and to what?
dig example.com +short
dig example.com A +trace # follow the full delegation chain
dig @1.1.1.1 example.com # bypass your local resolver
# 2. Reachability β is the host there at all?
ping -c 4 93.184.216.34
# 3. Path β where does it stop?
traceroute example.com # tracert on Windows
# 4. Ports β is anything listening?
ss -tulpn # local listening sockets (Linux)
ss -tn state established
nc -zv example.com 443 # can I open that remote port?
# 5. Application β what does the server actually say?
curl -v https://example.com
curl -I https://example.com # headers only
openssl s_client -connect example.com:443 -servername example.comStep 1 answers "is it DNS?" and it usually is. Compare dig against your resolver with dig @1.1.1.1 against a public one. Different answers mean a caching or split-horizon problem, not a server problem.
A failed ping is weak evidence. Many hosts and most cloud firewalls drop ICMP deliberately. ping failing while curl succeeds is normal and means nothing is wrong.
traceroute gaps are also normal. Routers that do not reply to ICMP show as * * * while still forwarding traffic perfectly. Only a consistent stop at the same hop, with nothing beyond it, is a real signal.
curl -v is the highest-information single command on this list. In one output you see the resolved IP, the TCP connection, the full TLS negotiation with certificate details, the request headers sent, and the response headers received.
The Five Mistakes
1. Concluding a host is down because ping fails. ICMP is routinely blocked. Test the actual port.
2. Assuming a DNS change is live everywhere. Every resolver caches until its TTL expires. Lower the TTL before migrating.
3. Trusting a browser to validate your TLS chain. Browsers cache intermediates. Verify with openssl s_client or curl.
4. Exposing database ports to 0.0.0.0/0. Bind to localhost or a private subnet, and put access behind a VPN or bastion.
5. Reading TIME_WAIT sockets as a leak. It is the normal end state of a closed TCP connection.
Print This Section
LAYERS Link β Internet(IP) β Transport(TCP/UDP) β Application(HTTP)
IP does not guarantee delivery; TCP adds it
PORTS 22 SSH Β· 53 DNS Β· 80 HTTP Β· 443 HTTPS+QUIC
3306 MySQL Β· 5432 Postgres Β· 6379 Redis Β· 27017 Mongo
TCP/UDP TCP = handshake, ordered, reliable UDP = fire and forget
QUIC = reliable streams over UDP, no TCP head-of-line block
DNS cache β resolver β root β TLD β authoritative
change not live everywhere until TTL expires
PRIVATE IP 10.0.0.0/8 Β· 172.16.0.0/12 Β· 192.168.0.0/16
/24 = 254 hosts Β· /32 = one host Β· 0.0.0.0/0 = everything
DIAGNOSE dig +short β ping β traceroute β ss -tulpn β curl -v
ping failing proves nothing (ICMP is often blocked)Nearly every "the network is broken" incident resolves to one question answered in the wrong order β so run dig, then ss, then curl -v, and let each command eliminate a layer before you form a theory.
π Next in this collection: System Design Cheat Sheet, or return to The Complete Developer Cheat Sheet Collection.
Advertisement
π¬ DiscussionPowered by GitHub Discussions
Frequently Asked Questions

AI & Software Engineering Editorial Team
The AiTechWorlds editorial team writes and reviews in-depth guides on artificial intelligence, machine learning, prompt engineering, programming, and developer tools. Every article is fact-checked against primary sources and kept up to date for working developers and CS students.
Not sure yet? Ask AI about this article
Get an instant, unbiased AI summary of βNetworking Cheat Sheet for Developers and CS Studentsβ.
Advertisement
Related Articles
Bash Scripting Cheat Sheet (The First Line Every Script Needs)
A practical Bash scripting cheat sheet β variables, conditionals, loops, functions, and the set -euo pipefail line that turns silent failure into loud failure.
15 Coding Interview Patterns That Solve Most Problems
The 15 coding interview patterns that cover most problems β the signal that identifies each one, a minimal code skeleton, and a two-minute recognition table.
CSS and Tailwind Cheat Sheet: Flexbox, Grid and Centering Solved
A practical CSS and Tailwind cheat sheet β Flexbox vs Grid decision rules, every centering method, responsive breakpoints, and the specificity traps.
Data Structures and Big-O Cheat Sheet for Coding Interviews
A practical big O cheat sheet β the complexity ladder with real examples, data structure operation tables, and how to state your complexity in an interview.