What happens when you open a website
A single curl https://example.org feels instant, yet before any HTML arrives your machine completes five distinct
network operations — and traffic can fail at any one of them for a different reason.
terminal · curl https://example.org
- DNS
UDP :53The resolver translatesexample.orginto an IP address — for example203.0.113.10(or IPv62001:db8::10). - Route & ARP
ip route · L2The kernel checks the routing table: the address is remote, so the packet heads to gateway10.0.10.1. ARP resolves that gateway’s MAC address. - TCP handshake
SYN · SYN-ACK · ACKThe client opens a connection from an ephemeral port (such as54322) to server port443in three packets. - TLS & SNI
ClientHello · TLS 1.3Both sides negotiate encryption; the client sendsexample.orgin the SNI field so the server picks the right certificate. - HTTP
GET / HTTP/2Inside the encrypted channel, the request goes out and200 OKreturns with the page body.
HTTP 200 OK response from web server
When a site fails to load, “the network is down” tells you nothing. Knowing this chain narrows every outage down to one question: at which of the five steps did the packet stop.
Four TCP/IP layers and why engineers say L2, L3, L4, L7
Textbooks often draw the 7-layer OSI model, yet the internet and the Linux kernel run the 4-layer TCP/IP stack. OSI session (L5) and presentation (L6) do not exist as separate layers in TCP/IP — applications and TLS handle their jobs. Still, OSI numbers stuck in daily engineering talk: “L2 switch”, “L3 router”, “L4 load balancer”, “L7 proxy”. Four working layers are all you need to keep in mind:
| Layer | Short name | Protocols | Address | Device / location | Linux tools |
|---|---|---|---|---|---|
| Link | L2 | Ethernet, Wi-Fi, ARP, VLAN | MAC (52:54:00:…) |
NIC, switch, br-* bridge |
ip link, ip neigh |
| Internet | L3 | IPv4, IPv6, ICMP | IP (203.0.113.10) |
Router, routing table, NAT | ip addr, ip route, mtr |
| Transport | L4 | TCP, UDP | Port (443, 53) |
Kernel sockets, nftables firewall |
ss, nc |
| Application | L7 | DNS, TLS, HTTP, SSH | Domain, URL, SNI | App, browser, Traefik | dig, curl -v, openssl |
Data hits the wire like nested envelopes: each layer wraps the block above it with its own header. That is encapsulation — a switch reads only L2, a router inspects up to L3, a firewall filters L3 and L4, and the web server receives clean HTTP.
0x0800 IPv4, 0x0806 ARP, 0x86DD IPv6The NIC verifies CRC32 in hardware and drops corrupted frames before the kernel sees them — which is why FCS rarely appears in tcpdump output.
The core rule of packet travel: MAC addresses live only until the next router, while IP addresses travel from
source to final destination (unless NAT rewrites them). When a router forwards a packet, it strips the old
Ethernet header, decrements TTL by 1, and wraps the same IP packet in a new frame addressed to the next hop’s
MAC.
Five misconceptions that waste hours of debugging
Shallow networking summaries leave behind bad habits. When debugging servers and containers, these five cost the most time:
ping does not test websites or ports
ping sends ICMP Echo (L3), which has no concept of ports. A server can answer ping while its web server is
dead — or silently drop ICMP at the firewall while HTTPS on port 443 serves traffic fine.
Timeouts and Connection refused have different causes
When a client hangs for 20 seconds and times out, a firewall is silently dropping packets (DROP) or a route is
missing. When it fails in milliseconds with Connection refused, the packet reached the server and the kernel
returned RST: nothing listens on that port, or a rule used REJECT.
NAT is not a firewall
A home router ignores unsolicited inbound IPv4 packets because no matching conntrack entry exists — not as a
security feature. Once IPv6 arrives without NAT, explicit firewall rules have to do that job
(nftables).
TCP does not guarantee delivery
Unplug the cable and no protocol can deliver a packet. TCP guarantees something else: using seq and ack
numbers, it detects loss, retransmits, reorders chunks, and reports a broken connection to the application if
replies stop coming.
tcpdump sees inbound traffic before the firewall
On inbound traffic, AF_PACKET capture sits ahead of netfilter hooks. That is why tcpdump on the server
shows incoming SYN packets that never reach nginx or a container: ufw or nftables drops them right after
capture.
Where traffic breaks: five common failures
Almost any server or home-network outage falls into one of the five scenarios below. Switch between them to see
where packets stop, what tcpdump prints, and which command to run first:
- Client✓ SYN >
- Router / NAT✓ SNAT
- nftables✓ accept :443
- Server :443✓ < SYN-ACK
00.000 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [S], seq 104928171, length 0 00.018 IP 203.0.113.10.443 > 10.0.10.42.54322: Flags [S.], seq 391820411, ack 104928172, length 0 00.018 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [.], ack 1, length 0
The three-way handshake finished in 18 ms — the connection entered ESTABLISHED, followed by TLS ClientHello.
ss -tn state established '( dport = :443 )'
- Client✓ SYN > (×3)
- Router / NAT✓ forwarded
- nftables / ufw✕ DROP (silent)
- Server :443— never arrived
00.000 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [S], seq 104928171, length 0 01.012 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [S], seq 104928171, length 0 03.044 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [S], seq 104928171, length 0
The firewall silently dropped packets (policy drop), so the client retries SYN at 1 s, 2 s, and 4 s. On the server itself, tcpdump still prints those SYN packets because capture happens before the firewall.
sudo nft list ruleset | grep -E 'dport 443|policy drop'
- Client✓ SYN >
- Router / NAT✓ forwarded
- nftables✓ allowed
- Server kernel✕ < RST (no listener)
00.000 IP 10.0.10.42.54322 > 203.0.113.10.8080: Flags [S], seq 104928171, length 0 00.017 IP 203.0.113.10.8080 > 10.0.10.42.54322: Flags [R.], seq 0, ack 104928172, length 0
The packet reached the server, yet nothing is listening on port 8080 (or the service listens only on 127.0.0.1), or a firewall rule uses reject. The client gets Connection refused immediately.
sudo ss -tulnp | grep 8080
- Client✓ TCP + small packets
- Tunnel (MTU 1420)✕ 1500 B packet + DF
- ICMP Frag Needed✕ blocked by firewall
- Server— stalls after Hello
00.018 IP 203.0.113.10.443 > 10.0.10.42.54322: Flags [S.], options [mss 1460] 00.021 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [P.], length 1448 00.425 IP 10.0.10.42.54322 > 203.0.113.10.443: Flags [P.], length 1448
The short handshake gets through, while the first full 1500-byte packet does not fit inside VPN/PPPoE; the ICMP Fragmentation Needed reply is dropped, leaving the connection stuck retransmitting.
ping -M do -s 1472 203.0.113.10
- Client✓ A? example.org
- Resolver :53✕ SERVFAIL / empty
- TCP :443— never started
- Server— no traffic
00.000 IP 10.0.10.42.49102 > 10.0.10.1.53: 4821+ A? example.org. (29) 00.042 IP 10.0.10.1.53 > 10.0.10.42.49102: 4821 ServFail 0/0/0 (29)
TCP never started: the resolver returned SERVFAIL (broken DNSSEC or unresponsive upstream) or NXDOMAIN (the domain does not exist).
dig +trace example.org and dig @1.1.1.1 example.org
Tools for inspecting networking on Linux
Older guides still reference ifconfig, netstat, route, and arp from net-tools. Modern Linux
distributions replaced them with iproute2 (ip and ss), which talks directly to the kernel over Netlink and
handles network namespaces (netns), IPv6, and Docker containers accurately.
| Layer | What it shows | When to use it | |
|---|---|---|---|
ip (iproute2) |
L2, L3 | Interfaces, addresses, ARP table (ip neigh), routes (ip route get) |
First check: is the link up, what is the IP, and where will a packet go |
ss (iproute2) |
L4 | Open sockets, listening processes (-tulnp), TCP states |
Check what listens on a port and on which address (0.0.0.0 vs. 127.0.0.1) |
mtr / ping |
L3 | Reachability, packet loss, and latency at every hop along the path | Locate which router drops packets or adds latency |
dig |
L7 (DNS) | A/AAAA/CNAME/TXT records, cache TTL, +trace delegation path |
Verify name resolution and compare your resolver against 1.1.1.1 |
curl -v |
L4, L7 | TCP connect, TLS handshake, certificate, SNI, and HTTP headers | Debug web services, Traefik proxies, redirects, and certificates |
tcpdump |
L2–L7 | Live packets on an interface and .pcap captures for Wireshark |
When logs stay silent: see every SYN, RST, retransmission, and DNS reply |
| If… | Run |
|---|---|
you are unsure where the kernel will route a packet to 203.0.113.10 |
ip route get 203.0.113.10 |
a browser or curl gets Connection refused |
sudo ss -tulnp on the server |
| a domain fails to load while the IP responds | dig example.org and dig @1.1.1.1 example.org |
| a site behind Traefik returns the wrong certificate or 502 | curl -vkI https://example.org |
| packets vanish and application logs are empty | sudo tcpdump -nn -i any and save to .pcap |
How this section is organized and where to start
The section is split into five parts from the bottom layer up — from wire frames to the Linux network stack. The full map of chapters and cheat sheets lives in the Networking section:
- New to networking — follow the chapters in order starting with part one: each chapter opens with live command output or a failure trace, explains the mechanism, and reinforces it with a short check.
- Already comfortable with the basics — jump straight to the chapter you need (such as NAT and
conntrack, ICMP and MTU, IPv6, or Linuxnetnsandveth), or go directly to thetcpdumptopic for packet capture and analysis.
Related topics on this site build on these fundamentals: kernel firewalls in nftables and The ufw firewall, container networking in Docker networks and Docker subnet clashes with home network, home routers in MikroTik and Wired on MikroTik, and reverse proxies with TLS in Traefik.
If it doesn’t work
ping 203.0.113.10 succeeds, while the website or SSH on the same server fails to open
- Cause
pingsends ICMP Echo and knows nothing about TCP ports. The server is reachable over IP, while the target port is blocked by a firewall or the service is not running.- Fix
- Test the specific port with
nc -zv -w 3 203.0.113.10 443orcurl -vk https://example.org. On the server, check what listens on that port withsudo ss -tulnp.
A connection hangs for 10–30 seconds and fails with Connection timed out, even though the port is open on the server
- Cause
- A firewall silently drops
SYNpackets (DROP), or the return route is missing. The client retriesSYNwith exponential backoff until it times out. - Fix
- Inspect firewall rules (
sudo nft list ruleset) and routing (ip route get 203.0.113.10). Intcpdump -nn, you will see repeatedFlags [S]packets with no reply.
Instant Connection refused right after running the command
- Cause
- The packet reached the server, and the kernel replied with
RST: nothing is listening on that port and address (often the service is bound only to127.0.0.1), or a firewall rule usesREJECT. - Fix
- Run
sudo ss -tulnp | grep :8080on the server and confirm the bind address is0.0.0.0(or::), not127.0.0.1.
tcpdump on the server shows incoming packets, while nginx, Traefik, or app logs stay empty
- Cause
tcpdumpcaptures incoming traffic viaAF_PACKETbeforenetfilterhooks run. The packet lands in the capture and is dropped a moment later byufwornftables.- Fix
- Check the
inputandforwardchains insudo nft list rulesetalong with drop counters. For Docker containers, inspectforwardas well (nftables).
SSH connects and accepts short commands, then freezes completely after ls -la or a file transfer
- Cause
- An MTU black hole: small packets (
SYN, short keystrokes) fit through a VPN or PPPoE link with a smaller MTU, while full 1500-byte frames get dropped because ICMPFragmentation Neededis blocked. - Fix
- Find the largest non-fragmented payload with
ping -M do -s 1472 203.0.113.10, lowering the size until replies arrive. Allow the required ICMP types or enable MSS clamping on the router.
curl: (6) Could not resolve host or Temporary failure in name resolution, while ping 1.1.1.1 works
- Cause
- IP routing to the internet works, while DNS is broken: the resolver is unreachable,
systemd-resolvedis misconfigured, or the domain has noA/AAAArecord. - Fix
- Compare the system resolver against a public one:
dig example.orgvs.dig @1.1.1.1 example.org. On Ubuntu, check system DNS status withresolvectl status.