Wrap-up

Networking cheat sheet and final exam: ports, RFCs, answers

lesson 19 / 1918 minpublished updated
Course contents
On this page
  1. Ports you should know
  2. Special addresses at a glance
  3. RFCs worth knowing
  4. Final exam: questions
  5. Final exam: answers
  6. The complete checklist: what I can do without documentation
  7. Roadmap: what to learn next

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

PortProtocolService
20, 21TCPFTP (data and control)
22TCPSSH, SFTP, SCP
23TCPTelnet (insecure, obsolete)
25TCPSMTP between mail servers
53UDP and TCPDNS
67, 68UDPDHCP (server and client)
69UDPTFTP
80TCPHTTP
88TCP and UDPKerberos
110, 995TCPPOP3, POP3S
123UDPNTP
143, 993TCPIMAP, IMAPS
161, 162UDPSNMP, SNMP traps
179TCPBGP
389, 636TCPLDAP, LDAPS
443TCP and UDPHTTPS (TCP), HTTP/3 and QUIC (UDP)
445TCPSMB
465, 587TCPSMTP submission (implicit TLS, STARTTLS)
500, 4500UDPIPsec IKE, NAT-T
514UDP and TCPSyslog
853TCP and UDPDNS over TLS, DNS over QUIC
1194UDPOpenVPN
1433TCPMicrosoft SQL Server
1812, 1813UDPRADIUS
1883, 8883TCPMQTT, MQTT over TLS
2049TCPNFS
2375, 2376TCPDocker API (without and with TLS; never expose it publicly)
2379, 2380TCPetcd
3306TCPMySQL, MariaDB
3389TCPRDP
3478UDP and TCPSTUN and TURN
4789UDPVXLAN
5060, 5061UDP and TCPSIP, SIP over TLS
5432TCPPostgreSQL
5672TCPAMQP (RabbitMQ)
6379TCPRedis
6443TCPKubernetes API server
8080, 8443TCPAlternative HTTP and HTTPS (common, not official)
9092TCPKafka
9200TCPElasticsearch and OpenSearch
10250TCPKubelet API
27017TCPMongoDB
51820UDPWireGuard

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

IPv4IPv6Meaning
127.0.0.0/8::1/128Loopback
0.0.0.0::Unspecified; when binding, it means all interfaces
10/8, 172.16/12, 192.168/16fc00::/7 (ULA)Private
169.254.0.0/16fe80::/10Link-local
100.64.0.0/10—CGNAT
224.0.0.0/4ff00::/8Multicast
255.255.255.255— (IPv6 has no broadcast)Limited broadcast
192.0.2.0/24 and two other blocks2001:db8::/32Documentation
—64:ff9b::/96NAT64
—2000::/3Global unicast

RFCs worth knowing

RFCTopic
791IPv4
792ICMP
768UDP
9293TCP (replaces RFC 793)
826ARP
1122Host requirements (the TCP/IP model)
1918Private IPv4 addresses
4632CIDR
6890Special-purpose address registry
2131DHCP
8200IPv6
4861, 4862NDP and SLAAC
4271BGP-4
6480RPKI
1034, 1035DNS
4033 to 4035DNSSEC
8484, 7858DNS over HTTPS, DNS over TLS
9110 to 9114HTTP semantics, HTTP/1.1, HTTP/2, HTTP/3
9000QUIC
8446TLS 1.3
9849Encrypted Client Hello
5280X.509 certificate profile
8555ACME
6962Certificate Transparency
5321SMTP
7208, 6376SPF, DKIM
4251 to 4254SSH
5905NTP
6455WebSocket
2119, 8174The meaning of MUST, SHOULD and MAY
2827BCP 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

  1. Tell the story of opening https://example.com, step by step, naming the protocol at each step.
  2. What is the maximum a 1 Gbps link can carry in MB/s? Why is it less in practice?
  3. What is the difference between bandwidth and latency? Which one can’t you simply buy more of, and why?
  4. What is the BDP, and what does it have to do with TCP?
  5. Name the seven OSI layers and the four TCP/IP layers, and say where TLS fits.
  6. What are the usual MTU and MSS on Ethernet, and why?
  7. How does a switch learn which MAC address is behind which port, and when does it flood?
  8. What is a VLAN, and what’s the difference between an access port and a trunk port?
  9. How does ARP work, and why is it insecure?
  10. Why is a loop a disaster in Ethernet, and what prevents it?

IP

  1. What are the network address, broadcast address and number of hosts for 172.20.45.130/27?
  2. Name the three private IPv4 ranges and the CGNAT range.
  3. What is longest prefix match?
  4. On a packet’s path from a laptop to a distant server, what changes at every hop and what doesn’t?
  5. How does traceroute work?
  6. What is an MTU black hole, and how do you fix it?
  7. How does PAT work, step by step, and why isn’t NAT a substitute for a firewall?
  8. What are the four DHCP messages, and what does a 169.254.x.x address mean?
  9. How do link-local and global addresses differ in IPv6, and what prefix does each LAN get?
  10. What did NDP replace? Where does the default gateway come from in IPv6?
  11. What is Happy Eyeballs, and why is it needed?
  12. Why shouldn’t you block ICMPv6 completely?

Transport

  1. What are the three port ranges, and what is the ephemeral range on Linux?
  2. What is a 5-tuple, and how can a server have millions of connections on one port?
  3. Explain the three-way handshake with its sequence and ACK numbers.
  4. Why does TIME_WAIT exist, and what do lots of CLOSE_WAIT sockets mean?
  5. What’s the difference between flow control and congestion control? What is slow start?
  6. How do CUBIC and BBR differ?
  7. What is head-of-line blocking in TCP, and how did QUIC solve it?
  8. What do ECONNREFUSED and ETIMEDOUT mean at the network level?
  9. Why does TCP have no “messages”, and what should you as a programmer do about it?

The Internet and its organizations

  1. What are an AS and BGP, and which port does BGP use?
  2. What’s the difference between transit and peering, and what role does an IXP play?
  3. What is anycast, and who uses it?
  4. What is a BGP hijack, and how does RPKI help?
  5. What do ICANN and IANA do? Which non-profit could the Internet not keep running without?
  6. Name the five RIRs. Which one covers the Middle East (Iran, for example)?
  7. How does the IETF work, and what does MUST mean in an RFC?
  8. How many root servers are there, and what exactly do they know?

Applications

  1. Walk through the resolution of a name, from the stub resolver to the authoritative server.
  2. Why isn’t a CNAME allowed at the apex of a domain?
  3. When does DNS use TCP?
  4. What does DNSSEC guarantee, and what doesn’t it?
  5. What’s the difference between 502 and 504?
  6. Name three main differences between HTTP/2 and HTTP/1.1, and two between HTTP/3 and HTTP/2.
  7. What are the steps of the TLS 1.3 handshake, and what is forward secrecy?
  8. What does certificate validation check?
  9. What do SPF, DKIM and DMARC each do?

Infrastructure and security

  1. How do layer 4 and layer 7 load balancers differ, and how do you get the client’s real IP behind them?
  2. How does an amplification DDoS attack work, and what role does BCP 38 play?

Final exam: answers

  1. 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.
  2. 125 MB/s (1000 ÷ 8). It’s less in practice because of Ethernet, IP and TCP headers, the gaps between frames, ACKs and retransmissions.
  3. 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.
  4. 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.
  5. 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.
  6. An MTU of 1500 and an MSS of 1460 (minus 20 bytes for IPv4 and 20 bytes for TCP).
  7. 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.
  8. 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.
  9. 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).
  10. Ethernet has no TTL field, so broadcasts circulate forever (a broadcast storm). STP or RSTP blocks ports to build a loop-free tree.
  11. /27 means a block size of 32, so the blocks are 0, 32, 64, 96, 128, 160 and so on. .130 falls in .128 to .159. Network: 172.20.45.128, broadcast: 172.20.45.159, and 30 hosts.
  12. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16; CGNAT: 100.64.0.0/10.
  13. Of all the routes that contain the destination, the most specific one (the longest prefix) is chosen.
  14. 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).
  15. 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.
  16. 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.
  17. 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.
  18. Discover, Offer, Request, Ack. 169.254.x.x means DHCP didn’t answer and the OS picked a link-local address for itself.
  19. 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.
  20. ARP, router discovery, autoconfiguration and duplicate address detection. The default gateway comes from router advertisements (not from DHCPv6).
  21. 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.
  22. Because NDP, router advertisements, PMTUD (Packet Too Big) and DAD are all ICMPv6. Without it, IPv6 doesn’t work.
  23. 0 to 1023 are well-known, 1024 to 49151 are registered, and 49152 to 65535 are dynamic. Linux uses 32768 to 60999 by default.
  24. (protocol, source IP, source port, destination IP, destination port). Every client with a different source IP or source port is a distinct connection.
  25. SYN with seq=x; SYN-ACK with seq=y and ack=x+1; ACK with ack=y+1. The ISN is random.
  26. 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).
  27. 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.
  28. 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.
  29. 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.
  30. 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.
  31. TCP is a byte stream; the boundaries between send calls aren’t preserved. Your protocol needs framing (a length prefix or a delimiter), and you have to call recv in a loop.
  32. 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.
  33. 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.
  34. 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.
  35. 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.
  36. 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.
  37. RIPE NCC, ARIN, APNIC, LACNIC and AFRINIC. The Middle East, including Iran, is in the RIPE NCC region.
  38. 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).
  39. 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.
  40. 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.
  41. A CNAME can’t share its name with any other record, and the apex always has SOA and NS records.
  42. When the answer is too large for UDP (the TC flag is set), for zone transfers (AXFR and IXFR), and with DoT.
  43. 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.
  44. 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.
  45. 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.
  46. 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.
  47. 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).
  48. 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.
  49. 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.
  50. 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 -v and 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 ipaddress module.
  • I can find the path and the MTU with ip route get, traceroute, mtr and tracepath.
  • 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 -w and 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

StepFocusSuggested resource
1Solidify the fundamentals with a textbookComputer Networking: A Top-Down Approach (Kurose and Ross)
2TCP/IP in depth, packet by packetTCP/IP Illustrated, Volume 1 (Stevens and Fall)
3Network performance on the webHigh Performance Browser Networking (Ilya Grigorik; free online)
4Network programmingBeej’s Guide to Network Programming (free); then build a full HTTP server or DNS resolver
5A certification to give your knowledge structureCompTIA Network+ or Cisco CCNA
6Linux networking and eBPFCilium and kernel documentation; bpftrace tools
7SecurityOWASP documentation; practice in CTFs and legal lab environments
8Internet governanceFree RIPE NCC Academy courses; RIPE and IETF meetings (in person, or online for free)