Wrap-up
Networking cheat sheet and final exam: ports, RFCs, answers
Course contents
This is the page to come back to after the course. It collects the ports, special addresses and RFCs worth knowing, a 50-question final exam with answers, a checklist of things you should be able to do without documentation, and a roadmap for what to study next.
Ports you should know
| Port | Protocol | Service |
|---|---|---|
| 20, 21 | TCP | FTP (data and control) |
| 22 | TCP | SSH, SFTP, SCP |
| 23 | TCP | Telnet (insecure, obsolete) |
| 25 | TCP | SMTP between mail servers |
| 53 | UDP and TCP | DNS |
| 67, 68 | UDP | DHCP (server and client) |
| 69 | UDP | TFTP |
| 80 | TCP | HTTP |
| 88 | TCP and UDP | Kerberos |
| 110, 995 | TCP | POP3, POP3S |
| 123 | UDP | NTP |
| 143, 993 | TCP | IMAP, IMAPS |
| 161, 162 | UDP | SNMP, SNMP traps |
| 179 | TCP | BGP |
| 389, 636 | TCP | LDAP, LDAPS |
| 443 | TCP and UDP | HTTPS (TCP), HTTP/3 and QUIC (UDP) |
| 445 | TCP | SMB |
| 465, 587 | TCP | SMTP submission (implicit TLS, STARTTLS) |
| 500, 4500 | UDP | IPsec IKE, NAT-T |
| 514 | UDP and TCP | Syslog |
| 853 | TCP and UDP | DNS over TLS, DNS over QUIC |
| 1194 | UDP | OpenVPN |
| 1433 | TCP | Microsoft SQL Server |
| 1812, 1813 | UDP | RADIUS |
| 1883, 8883 | TCP | MQTT, MQTT over TLS |
| 2049 | TCP | NFS |
| 2375, 2376 | TCP | Docker API (without and with TLS; never expose it publicly) |
| 2379, 2380 | TCP | etcd |
| 3306 | TCP | MySQL, MariaDB |
| 3389 | TCP | RDP |
| 3478 | UDP and TCP | STUN and TURN |
| 4789 | UDP | VXLAN |
| 5060, 5061 | UDP and TCP | SIP, SIP over TLS |
| 5432 | TCP | PostgreSQL |
| 5672 | TCP | AMQP (RabbitMQ) |
| 6379 | TCP | Redis |
| 6443 | TCP | Kubernetes API server |
| 8080, 8443 | TCP | Alternative HTTP and HTTPS (common, not official) |
| 9092 | TCP | Kafka |
| 9200 | TCP | Elasticsearch and OpenSearch |
| 10250 | TCP | Kubelet API |
| 27017 | TCP | MongoDB |
| 51820 | UDP | WireGuard |
The official reference is IANA’s “Service Name and Transport Protocol Port Number Registry”. On Linux, /etc/services is a local copy of it.
Special addresses at a glance
| IPv4 | IPv6 | Meaning |
|---|---|---|
127.0.0.0/8 | ::1/128 | Loopback |
0.0.0.0 | :: | Unspecified; when binding, it means all interfaces |
10/8, 172.16/12, 192.168/16 | fc00::/7 (ULA) | Private |
169.254.0.0/16 | fe80::/10 | Link-local |
100.64.0.0/10 | — | CGNAT |
224.0.0.0/4 | ff00::/8 | Multicast |
255.255.255.255 | — (IPv6 has no broadcast) | Limited broadcast |
192.0.2.0/24 and two other blocks | 2001:db8::/32 | Documentation |
| — | 64:ff9b::/96 | NAT64 |
| — | 2000::/3 | Global unicast |
RFCs worth knowing
| RFC | Topic |
|---|---|
| 791 | IPv4 |
| 792 | ICMP |
| 768 | UDP |
| 9293 | TCP (replaces RFC 793) |
| 826 | ARP |
| 1122 | Host requirements (the TCP/IP model) |
| 1918 | Private IPv4 addresses |
| 4632 | CIDR |
| 6890 | Special-purpose address registry |
| 2131 | DHCP |
| 8200 | IPv6 |
| 4861, 4862 | NDP and SLAAC |
| 4271 | BGP-4 |
| 6480 | RPKI |
| 1034, 1035 | DNS |
| 4033 to 4035 | DNSSEC |
| 8484, 7858 | DNS over HTTPS, DNS over TLS |
| 9110 to 9114 | HTTP semantics, HTTP/1.1, HTTP/2, HTTP/3 |
| 9000 | QUIC |
| 8446 | TLS 1.3 |
| 9849 | Encrypted Client Hello |
| 5280 | X.509 certificate profile |
| 8555 | ACME |
| 6962 | Certificate Transparency |
| 5321 | SMTP |
| 7208, 6376 | SPF, DKIM |
| 4251 to 4254 | SSH |
| 5905 | NTP |
| 6455 | WebSocket |
| 2119, 8174 | The meaning of MUST, SHOULD and MAY |
| 2827 | BCP 38, ingress filtering |
Final exam: questions
Answer each question out loud without looking anything up, then compare with the answers below. The goal: at least 45 out of 50.
Fundamentals and the lower layers
- Tell the story of opening
https://example.com, step by step, naming the protocol at each step. - What is the maximum a 1 Gbps link can carry in MB/s? Why is it less in practice?
- What is the difference between bandwidth and latency? Which one can’t you simply buy more of, and why?
- What is the BDP, and what does it have to do with TCP?
- Name the seven OSI layers and the four TCP/IP layers, and say where TLS fits.
- What are the usual MTU and MSS on Ethernet, and why?
- How does a switch learn which MAC address is behind which port, and when does it flood?
- What is a VLAN, and what’s the difference between an access port and a trunk port?
- How does ARP work, and why is it insecure?
- Why is a loop a disaster in Ethernet, and what prevents it?
IP
- What are the network address, broadcast address and number of hosts for
172.20.45.130/27? - Name the three private IPv4 ranges and the CGNAT range.
- What is longest prefix match?
- On a packet’s path from a laptop to a distant server, what changes at every hop and what doesn’t?
- How does traceroute work?
- What is an MTU black hole, and how do you fix it?
- How does PAT work, step by step, and why isn’t NAT a substitute for a firewall?
- What are the four DHCP messages, and what does a
169.254.x.xaddress mean? - How do link-local and global addresses differ in IPv6, and what prefix does each LAN get?
- What did NDP replace? Where does the default gateway come from in IPv6?
- What is Happy Eyeballs, and why is it needed?
- Why shouldn’t you block ICMPv6 completely?
Transport
- What are the three port ranges, and what is the ephemeral range on Linux?
- What is a 5-tuple, and how can a server have millions of connections on one port?
- Explain the three-way handshake with its sequence and ACK numbers.
- Why does TIME_WAIT exist, and what do lots of CLOSE_WAIT sockets mean?
- What’s the difference between flow control and congestion control? What is slow start?
- How do CUBIC and BBR differ?
- What is head-of-line blocking in TCP, and how did QUIC solve it?
- What do ECONNREFUSED and ETIMEDOUT mean at the network level?
- Why does TCP have no “messages”, and what should you as a programmer do about it?
The Internet and its organizations
- What are an AS and BGP, and which port does BGP use?
- What’s the difference between transit and peering, and what role does an IXP play?
- What is anycast, and who uses it?
- What is a BGP hijack, and how does RPKI help?
- What do ICANN and IANA do? Which non-profit could the Internet not keep running without?
- Name the five RIRs. Which one covers the Middle East (Iran, for example)?
- How does the IETF work, and what does MUST mean in an RFC?
- How many root servers are there, and what exactly do they know?
Applications
- Walk through the resolution of a name, from the stub resolver to the authoritative server.
- Why isn’t a CNAME allowed at the apex of a domain?
- When does DNS use TCP?
- What does DNSSEC guarantee, and what doesn’t it?
- What’s the difference between 502 and 504?
- Name three main differences between HTTP/2 and HTTP/1.1, and two between HTTP/3 and HTTP/2.
- What are the steps of the TLS 1.3 handshake, and what is forward secrecy?
- What does certificate validation check?
- What do SPF, DKIM and DMARC each do?
Infrastructure and security
- How do layer 4 and layer 7 load balancers differ, and how do you get the client’s real IP behind them?
- How does an amplification DDoS attack work, and what role does BCP 38 play?
Final exam: answers
- Parse the URL; DNS (caches first, then the recursive resolver via the root, TLD and authoritative servers); the routing decision (send to the default gateway); ARP for the gateway’s MAC address; the TCP handshake (or QUIC); NAT in the router; crossing ASes along BGP routes, probably ending at a CDN; the TLS handshake and certificate check; the HTTP request and response; rendering and follow-up requests over the same connection.
- 125 MB/s (1000 ÷ 8). It’s less in practice because of Ethernet, IP and TCP headers, the gaps between frames, ACKs and retransmissions.
- Bandwidth is how much data a link carries per second; latency is how long one packet takes to arrive (RTT: there and back). You can buy more bandwidth, but latency has a floor set by the speed of light in fiber (about 200,000 km/s), so the only way to reduce it is to get closer: a CDN, or fewer round trips.
- Bandwidth × RTT: the amount of data in flight on the path. The TCP window has to be at least that large to fill the link.
- Physical, Data Link, Network, Transport, Session, Presentation, Application; and Link, Internet, Transport, Application. TLS sits between transport and application: usually layers 6 and 5 in OSI, and part of the application layer in TCP/IP.
- An MTU of 1500 and an MSS of 1460 (minus 20 bytes for IPv4 and 20 bytes for TCP).
- It fills its MAC table from the source MAC of every incoming frame. If it doesn’t know the destination, or the frame is broadcast or multicast, it floods the frame out of every port except the one it came in on.
- A VLAN splits one switch into several logical broadcast domains. An access port belongs to one VLAN, without tags; a trunk carries several VLANs using 802.1Q tags.
- A broadcast request for an IP, a unicast reply with the MAC address, and a cache. There’s no authentication: anyone can send a fake reply (ARP spoofing and MITM).
- Ethernet has no TTL field, so broadcasts circulate forever (a broadcast storm). STP or RSTP blocks ports to build a loop-free tree.
/27means a block size of 32, so the blocks are 0, 32, 64, 96, 128, 160 and so on..130falls in.128to.159. Network:172.20.45.128, broadcast:172.20.45.159, and 30 hosts.10.0.0.0/8,172.16.0.0/12,192.168.0.0/16; CGNAT:100.64.0.0/10.- Of all the routes that contain the destination, the most specific one (the longest prefix) is chosen.
- The source and destination MAC addresses change at every hop; the TTL is decremented and the checksum updated; the IP addresses stay the same (unless there’s NAT).
- It sends packets with a TTL of 1, 2, 3 and so on. Each router that brings the TTL to zero sends back an ICMP Time Exceeded, which identifies it. The destination answers with Port Unreachable, an Echo Reply or a SYN-ACK.
- It happens when PMTUD doesn’t work because ICMP “Fragmentation Needed” is blocked, so large packets silently disappear. Fixes: allow the necessary ICMP, use MSS clamping, or lower the MTU.
- The router rewrites the source to its public IP and a free port and records the mapping in a table (conntrack); replies are sent back using the same table. NAT makes no security decisions, and IPv6 usually has no NAT at all; you need a firewall with a default-deny policy.
- Discover, Offer, Request, Ack.
169.254.x.xmeans DHCP didn’t answer and the OS picked a link-local address for itself. - A link-local address (
fe80::/10) works only on its own link and is configured automatically; a global address (2000::/3) is routable on the Internet. Each LAN gets a/64. - ARP, router discovery, autoconfiguration and duplicate address detection. The default gateway comes from router advertisements (not from DHCPv6).
- Trying IPv6 and IPv4 almost simultaneously and using whichever connects first. Without it, a broken IPv6 path means several seconds of delay on every connection.
- Because NDP, router advertisements, PMTUD (Packet Too Big) and DAD are all ICMPv6. Without it, IPv6 doesn’t work.
- 0 to 1023 are well-known, 1024 to 49151 are registered, and 49152 to 65535 are dynamic. Linux uses 32768 to 60999 by default.
- (protocol, source IP, source port, destination IP, destination port). Every client with a different source IP or source port is a distinct connection.
- SYN with seq=x; SYN-ACK with seq=y and ack=x+1; ACK with ack=y+1. The ISN is random.
- TIME_WAIT (2 MSL, 60 seconds on Linux) stops old segments from getting mixed into a new connection and covers a lost final ACK. Lots of CLOSE_WAIT means your application isn’t closing its sockets (a bug and a leak).
- Flow control (rwnd) protects the receiver; congestion control (cwnd) protects the network. Slow start: cwnd starts at about 10 segments and doubles every RTT until there’s loss or it reaches ssthresh.
- CUBIC is loss-based and the default on most systems. BBR models the bandwidth and RTT, and does much better on links with random loss.
- One lost segment stops delivery of all the data after it, even data belonging to other streams (a serious problem for HTTP/2). QUIC has independent streams at the transport level.
- Refused: the host is up and answered with an RST, saying nobody is listening on that port. Timed out: no answer came back at all, because of a firewall, a routing problem or a host that’s down.
- TCP is a byte stream; the boundaries between
sendcalls aren’t preserved. Your protocol needs framing (a length prefix or a delimiter), and you have to callrecvin a loop. - An AS is a network under a single administration and routing policy, with one ASN. BGP is the protocol ASes use to announce routes to each other; it runs on TCP port 179.
- Transit: paying for access to the whole Internet. Peering: exchanging traffic between the two sides’ customers, usually for free. IXP: a place where hundreds of networks peer with each other over a single connection.
- Announcing one prefix from many locations, so BGP takes each user to the nearest one. Root servers, public DNS resolvers (
1.1.1.1,8.8.8.8) and CDNs use it. - Announcing a prefix the AS doesn’t own (or a more specific prefix). RPKI uses signed ROAs to state which AS is allowed to announce a prefix, and routers reject invalid announcements.
- ICANN (a non-profit) performs the IANA functions through PTI: the DNS root zone, allocating IP addresses and ASNs to the RIRs, and the protocol parameter registries. It also accredits registrars. So the standard answer to the second part is ICANN and IANA.
- RIPE NCC, ARIN, APNIC, LACNIC and AFRINIC. The Middle East, including Iran, is in the RIPE NCC region.
- It’s open, with no membership, and works through working groups and “rough consensus and running code”. RFCs never change; a new RFC makes an old one obsolete. MUST means an absolute requirement for interoperability (RFC 2119).
- 13 identities (a to m), run by 12 operators, with about two thousand instances through anycast. They only know where the servers for each TLD are.
- The stub (its cache and
/etc/hosts) asks the recursive resolver. The resolver asks the root (which refers it to the TLD), then the TLD (which refers it to the authoritative server), then the authoritative server (which gives the answer), and caches the result for the TTL. - A CNAME can’t share its name with any other record, and the apex always has SOA and NS records.
- When the answer is too large for UDP (the TC flag is set), for zone transfers (AXFR and IXFR), and with DoT.
- The authenticity and integrity of the answer (it came from the zone’s owner and wasn’t modified), and proof that a name doesn’t exist. Not confidentiality.
- 502: the proxy got an invalid response from the backend, or the connection was refused or dropped. 504: the backend didn’t answer before the timeout.
- HTTP/2: binary framing, multiplexing over one connection, and header compression with HPACK. HTTP/3: it runs on QUIC over UDP, with no head-of-line blocking at the transport level, and a handshake combined with TLS (1 RTT, or 0-RTT) plus connection migration.
- ClientHello with a key share and SNI; ServerHello with a key share; then, encrypted, EncryptedExtensions, Certificate, CertificateVerify and Finished; then the client’s Finished. One RTT. Forward secrecy: the ECDHE keys are ephemeral, so a leaked server key doesn’t decrypt past traffic.
- The signatures along the chain up to a trusted root, the validity dates (and so the system clock), the name matching the SAN, and that the certificate hasn’t been revoked (CRL).
- SPF: the IPs allowed to send mail for the domain. DKIM: a signature on the message with a key published in DNS. DMARC: the policy for when SPF or DKIM don’t align, plus reporting.
- L4 works on IPs and ports, per connection; L7 reads the whole request and decides per request. The real IP:
X-Forwarded-For(behind L7) or the PROXY protocol (behind L4), trusted only when it comes from your own trusted proxies. - The attacker sends small UDP requests to public servers (DNS, NTP, Memcached) with the victim’s IP spoofed as the source, and the large responses flood the victim. BCP 38 (ingress filtering at ISPs) makes spoofing the source IP impossible.
The complete checklist: what I can do without documentation
- I can capture a packet with
tcpdump -vand explain every layer and every important field. - I can build a LAN, a router and NAT to the Internet with network namespaces.
- I can solve any subnetting problem in my head and verify it with Python’s
ipaddressmodule. - I can find the path and the MTU with
ip route get,traceroute,mtrandtracepath. - I can write a dual-stack (IPv4 and IPv6) server and a client with timeouts in Python.
- I can recognize a TCP handshake and teardown in tcpdump and spot retransmissions.
- I can follow a complete resolution with
dig +trace, and I have written a DNS client from scratch. - I can measure DNS, TCP, TLS and TTFB times with
curl -wand isolate the layers with--resolve. - I can inspect a site’s certificate chain with openssl and build a private CA.
- I can set up a stateful firewall with nftables and a tunnel with WireGuard.
- I can find a company’s ASN and prefixes and check their RPKI status.
- I can explain the roles of ICANN, IANA, the IETF, the RIRs and the root servers to someone else.
- I can design a VPC with public and private subnets.
- For ten common failure scenarios, I know the first hypothesis and the first command to run.
Roadmap: what to learn next
| Step | Focus | Suggested resource |
|---|---|---|
| 1 | Solidify the fundamentals with a textbook | Computer Networking: A Top-Down Approach (Kurose and Ross) |
| 2 | TCP/IP in depth, packet by packet | TCP/IP Illustrated, Volume 1 (Stevens and Fall) |
| 3 | Network performance on the web | High Performance Browser Networking (Ilya Grigorik; free online) |
| 4 | Network programming | Beej’s Guide to Network Programming (free); then build a full HTTP server or DNS resolver |
| 5 | A certification to give your knowledge structure | CompTIA Network+ or Cisco CCNA |
| 6 | Linux networking and eBPF | Cilium and kernel documentation; bpftrace tools |
| 7 | Security | OWASP documentation; practice in CTFs and legal lab environments |
| 8 | Internet governance | Free RIPE NCC Academy courses; RIPE and IETF meetings (in person, or online for free) |