Blog / Topic

Networking

Networking · Part 9 ·

Finding where a request breaks

A request passes the name, the route, the port, the padlock and the answer. Each tool checks one of these steps. Go in order and stop at the first failure, and curl's error code and timings show where to look.

namedig(6)routeip route getportnc -zv(7) (28)padlockopenssl(60)answercurl -v500the first failure stops youhere: no answer to the SYNone question eachin order, stop at the first failurewhere the time wenttcpdump: any reply?the last word
Networking · Part 8 ·

One front door for many programs

A reverse proxy is one address in front of many programs. It ends the client's connection and opens its own. It takes turns between the programs, but a health check that only proves the port is open sends requests into a broken one.

frontone front doorit opens its own connectionapp1app2500takes turnsapp1, then app2open but brokentry the other roomX-Forwarded-For:client 172.21.0.5it writes who askedin a headerproxy_next_upstream http_500retry on a real failurenot only on a closed portbackends see the proxythe client is in the header
Networking · Part 7 ·

Where a container's network ends

A container has its own network on a private street inside the host. Docker joins that street to the outside with two rewrite rules, one for traffic that leaves and one for each published port. The second rule is applied before the host's firewall rules for incoming traffic.

your firewallin: a DNAT rule8080 becomes 172.17.0.2:80-p 8080:80web = .2names: Docker's own DNSonly on networks you createMASQUERADEinternetout: MASQUERADEthe rewrite from part 6iptables -t nat -SDocker writes its own rulesin front of your firewall
Networking · Part 6 ·

Why your address is borrowed

A machine does not own its address. A DHCP server lends it, usually with a gateway and a resolver, and NAT rewrites it on the way out. A server on the internet sees the address of the translator, not yours.

a lease?an address is lentDISCOVER, OFFER, ACKlease192.168.50.147/24gateway 192.168.50.1time: 120 sa leaseaddress, gateway, time limitroutertablefrom 10.0.1.2from 10.0.2.1serverNAT: a new return addresson every packet that leavesiptables ... MASQUERADEa table rememberswho each connection isthe server sees the routernever the machine behind it
Networking · Part 5 ·

What the padlock proves

HTTPS wraps the plain text of part 4, so nobody on the path can read it or change it unnoticed. The padlock proves that the name you typed matches a certificate signed by someone your machine trusts. It does not prove that the site is honest.

example.comvalid 90 daysan ID cardname, signer, dateroot you trustissuerexample.comsignature chainends at a root you trustprivate + unchangednobody can read or edit it?openssl s_clientit shows the cardthree checks: name, dates, chainthe padlock is not a promisea valid card, not an honest site
Networking · Part 4 ·

HTTP is just text on a connection

A web request is a few lines of plain text sent over an open connection, and the answer is a few more lines. Once you can read them, the output of `curl -v` is easy to follow. The versions of HTTP change how many requests share one connection.

requestGET / HTTP/1.1Host: example.comAccept: */*responseHTTP/1.1 200 OKContent-Type: text/html<html> ... </html>both sides are plain textfirst line, notes, empty line, contentone connectionreused for the next request1.12 / 3curl -v http://example.comevery line, both ways> we send, < we receivehow many fit at onceHTTP/1.1, 2 and 3 differ here
Networking · Part 3 ·

What TCP promises and what it does not

TCP delivers your data in order, or it reports an error. How soon it reports depends on timers you did not set. The two errors, refused and timed out, show two different ways a connection fails.

serverSYNSYN-ACKACKthree packets open itSYN, SYN-ACK, ACKport 9001refused: instant nonothing listens on that porttimed out: silenceit waits about 2 minutesnc -zv -w 3 host portset your own deadlineTCP will wait minutesretries wait longerabout 2 minutes in all
Networking · Part 2 ·

How a name becomes an address

A packet needs an address, but people type names. DNS is a chain of questions, and every answer is kept in a cache until its time limit ends, so a changed record does not change everywhere at once.

example.com?ask the resolvernot the whole internetroot.comowner104.20.23.154a chain of officesonly the last gives the address104.20.23.154kept for the TTLthen asked againdig +trace example.comask each officedig +trace, step by steprecord changed?caches still say the old one
Networking · Part 1 ·

A packet only knows the next step

A machine has no map of the internet. For every packet it asks who should get it next. The most specific route answers, and a wrong route changes only the addresses in its range.

10.15.5networkhostnetwork + hostthe /16 marks the split10.0.0.0/810.1.0.0/1610.1.2.3/32defaultnarrowest winsorder is ignoredgatewayno sign matches?hand it to the gatewayip route get 10.1.5.5ask the kernelthe real decision, not a guessone wrong linebreaks only its own range

New posts by email

One email when a post ships, about twice a month. Nothing else, and one click to leave.

Latest: Finding where a request breaks · RSS