Skip to content
Tutorials Center
My learning

Topics

Lesson 78 of 79 ยท Practice and Review

Computer Networks Interview Questions

Prepare for networking interviews with 48 questions and clear answers on layers, TCP and UDP, DNS, HTTP, TLS, subnetting and troubleshooting, plus live Python checks.

Networking interviews tend to follow a pattern. They start with vocabulary (what is a switch, what is a port), move to protocol behavior (what happens in a TCP handshake, how does DNS resolve a name), and finish with a scenario ("the site is slow, what do you do?"). Interviewers rarely want a recited definition. They want to hear that you know why a protocol works the way it does, and that you can reason from first principles when you hit a case you have not memorized.

This lesson collects 48 questions in eight groups, each with a short, accurate answer you can say out loud in under a minute. The answers point back to the full lessons so you can go deeper wherever you feel shaky. Two small live editors at the end let you check the arithmetic questions (subnetting and address types) in seconds, which is the part people most often fumble under pressure. Everything else is read-only.

When you answer, name the layer, then the mechanism, then the trade-off. "TCP is reliable" is a start. "TCP numbers every byte, acknowledges cumulatively and retransmits on timeout or three duplicate ACKs, and it pays for that with a handshake and head-of-line blocking" is an answer.

Fundamentals and layers

1. What is a computer network? A set of devices (hosts) connected by links and intermediate devices so they can exchange data using agreed protocols. See What Is a Computer Network?.

2. What is the difference between circuit switching and packet switching? Circuit switching reserves a path and bandwidth for the whole call (classic telephone). Packet switching splits data into packets that share links and are forwarded independently, which uses links more efficiently for bursty traffic but allows queuing delay and loss. See How Data Travels.

3. Name the seven OSI layers. Physical, Data Link, Network, Transport, Session, Presentation, Application. The TCP/IP model merges the top three into one application layer and is the model the Internet actually uses. See Layered Models.

4. What is encapsulation? Each layer wraps the data from the layer above in its own header (and sometimes a trailer). Data becomes a segment, then a packet, then a frame, then bits. The receiver reverses the process, which is decapsulation.

5. What is the difference between a protocol and a service? A service is what a layer offers to the layer above (for example reliable byte delivery). A protocol is the set of rules two peers at the same layer follow to provide it (for example TCP).

6. Bandwidth versus latency versus throughput? Bandwidth is the maximum rate a link can carry. Latency is how long a bit takes to travel. Throughput is the rate you actually achieve, limited by the slowest link, protocol behavior and loss. A satellite link can have high bandwidth and high latency at the same time. See Bandwidth, Latency, Throughput and Loss.

7. What makes up the delay of a packet on one hop? Processing delay (reading the header), queuing delay (waiting for the output link), transmission delay (packet length divided by link rate) and propagation delay (distance divided by signal speed). Only queuing varies a lot.

8. What is the bandwidth-delay product? Link rate multiplied by round-trip time: the number of bytes that must be in flight to keep the pipe full. A TCP window smaller than this wastes capacity.

9. Hub, switch and router: what is the difference? A hub repeats bits to every port (one collision domain). A switch forwards frames by destination MAC address and gives every port its own collision domain. A router forwards packets by IP address and separates broadcast domains. See Switches, Bridges and MAC Learning.

10. How does a switch learn? It records the source MAC address of each incoming frame against the port it arrived on. A frame to a known destination goes out of one port; an unknown or broadcast destination is flooded to all ports except the one it came from.

11. What is a collision domain and a broadcast domain? A collision domain is a segment where simultaneous transmissions interfere (a hub, or half-duplex Ethernet). A broadcast domain is the set of devices that receive a layer 2 broadcast. Switch ports split collision domains; routers (and VLANs) split broadcast domains.

12. What is the purpose of the Spanning Tree Protocol? To prevent layer 2 loops. Ethernet frames have no TTL, so a loop would circulate broadcasts forever. STP blocks redundant links and unblocks one if the active path fails.

13. What is a VLAN? A logical broadcast domain defined in software on switches, tagged on trunk links with a 4-byte 802.1Q header that carries a 12-bit VLAN ID. See VLANs and ARP.

14. What does ARP do? It maps a known IPv4 address on the local network to a MAC address. The sender broadcasts "who has this IP?" and the owner replies with a unicast message. Results are cached for a short time. ARP has no authentication, which makes ARP spoofing possible.

15. What is a CRC and why use it instead of a checksum? A cyclic redundancy check treats the data as a polynomial and sends the remainder of a division. It detects all bursts up to the check length and is cheap in hardware, so it fits frames. See Framing and Error Detection.

16. What are the minimum and maximum Ethernet frame sizes? Minimum 64 bytes including header and CRC; the standard payload limit (MTU) is 1,500 bytes, so a frame is at most 1,518 bytes (1,522 with a VLAN tag). See Ethernet and Frames.

17. CSMA/CD versus CSMA/CA? CSMA/CD (wired Ethernet, now mostly unused with full duplex switches) detects a collision while sending and backs off. CSMA/CA (Wi-Fi) cannot hear a collision while transmitting, so it avoids them with random backoff and acknowledgments, optionally RTS/CTS. See Wi-Fi and 802.11.

IP addressing and routing

18. How many usable hosts does a /26 give? A /26 leaves 6 host bits: 26 = 64 addresses, minus the network and broadcast addresses, so 62 usable. See Subnetting and Subnet Masks.

19. Which address ranges are private? 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918). Also useful: 127.0.0.0/8 loopback, 169.254.0.0/16 link-local (the address a host gives itself when DHCP fails) and 100.64.0.0/10 for carrier-grade NAT. See IPv4 Addresses.

20. What is CIDR? Classless Inter-Domain Routing: addresses are written with a prefix length (192.0.2.0/24) instead of fixed classes, so blocks can be any size and routes can be aggregated. See CIDR, VLSM and Route Aggregation.

21. What is longest-prefix match? When several routes match a destination, the router uses the one with the longest prefix (most specific). A /24 route beats a /16, which beats the default route 0.0.0.0/0.

22. What does the TTL field do? It is decremented by every router; at zero the packet is discarded and an ICMP Time Exceeded message is sent back. It stops packets circulating forever in a routing loop and is the mechanism behind traceroute. See The IPv4 Packet and Fragmentation.

23. What is fragmentation, and what is path MTU discovery? If a packet exceeds a link's MTU, IPv4 can split it into fragments that the destination reassembles. Modern hosts set the Don't Fragment bit and use ICMP "fragmentation needed" messages to find the smallest MTU on the path. IPv6 routers never fragment.

24. Why IPv6? IPv4's 32 bits give about 4.3 billion addresses; IPv6 has 128 bits. It also simplifies the header (fixed 40 bytes), removes broadcast in favor of multicast, and supports stateless address autoconfiguration. See IPv6.

25. What does NAT do and what problems does it cause? Network Address Port Translation lets many private hosts share one public address by rewriting addresses and ports and keeping a translation table. It breaks inbound connections, complicates peer-to-peer and protocols that embed addresses. See NAT and Private Networks.

26. Describe DHCP. A client broadcasts Discover, a server offers an address (Offer), the client Requests it, and the server Acknowledges. The address comes with a lease, a mask, a gateway and DNS servers. See DHCP.

27. Link-state versus distance-vector routing? Link-state (OSPF) floods the full topology to every router, which runs Dijkstra. Distance-vector (RIP) shares only distance tables with neighbors and can suffer from count-to-infinity. See Link-State Routing and Dijkstra and Distance-Vector Routing.

28. What is BGP and why is it special? The path-vector protocol that exchanges reachability between autonomous systems. Its decisions follow business policy, not just shortest path, and it trusts what neighbors announce, which is why route leaks and hijacks happen. See BGP and Inter-Domain Routing.

29. What is ICMP used for? Error reporting and diagnostics at the IP layer: echo request and reply (ping), destination unreachable, time exceeded (traceroute). See ICMP.

Transport layer

30. TCP versus UDP? TCP gives a reliable, ordered byte stream with flow and congestion control after a handshake. UDP sends independent datagrams with an 8-byte header and no guarantees, which suits DNS, real-time media and protocols that build their own reliability (like QUIC). See UDP.

31. What is a port and what is a socket? A port is a 16-bit number that identifies an application on a host. A connection is identified by the four-tuple of source IP, source port, destination IP and destination port. Well-known ports are 0 to 1023, registered ports 1024 to 49151, dynamic ports 49152 to 65535.

32. Explain the three-way handshake. The client sends SYN with its initial sequence number, the server replies SYN-ACK with its own, and the client sends ACK. Both sides now know each other's starting numbers and that the peer is alive. See TCP Segments and the Three-Way Handshake.

33. What is a SYN flood and how is it mitigated? An attacker sends many SYNs without completing the handshake, filling the server's half-open connection table. SYN cookies encode the connection state in the sequence number so the server stores nothing until the final ACK arrives.

34. How does TCP close a connection? Each direction is closed separately with FIN and ACK (four segments), which allows half-close. The side that closes first keeps the connection in TIME_WAIT for twice the maximum segment lifetime so late duplicates cannot confuse a new connection. See TCP Connection Teardown.

35. What does a pile of CLOSE_WAIT connections mean? The remote side closed, but the local application never called close. It is almost always a bug in the application (a leaked socket), not a network problem.

36. How does TCP achieve reliability? Sequence numbers, cumulative acknowledgments, a retransmission timer based on measured RTT, and fast retransmit after three duplicate ACKs, with SACK to report gaps. See TCP Reliability.

37. Flow control versus congestion control? Flow control protects the receiver: the sender may not exceed the advertised receive window. Congestion control protects the network: the sender also limits itself to a congestion window that it grows and shrinks from loss or delay signals. The sender obeys the smaller of the two. See TCP Flow Control and TCP Congestion Control.

38. Explain slow start and AIMD. Slow start doubles the congestion window every round trip until a threshold or a loss. After that, congestion avoidance adds about one segment per round trip (additive increase) and halves the window on loss (multiplicative decrease).

39. What is head-of-line blocking? A lost packet delays everything behind it. On one TCP connection all data waits for the missing segment even if later data arrived. HTTP/2 multiplexes streams on one TCP connection and still suffers it; QUIC gives each stream independent delivery. See QUIC, SCTP and Modern Transports.

DNS, HTTP and the web

40. How does DNS resolve a name? The stub resolver asks a recursive resolver, which checks its cache, then asks a root server, a top-level-domain server and the domain's authoritative server in turn. Answers are cached for their TTL. See DNS.

41. Name common DNS record types. A (IPv4 address), AAAA (IPv6), CNAME (alias), MX (mail server), NS (name server), TXT (free text, often SPF and verification), PTR (reverse lookup), SOA (zone metadata).

42. What is the difference between HTTP/1.1, HTTP/2 and HTTP/3? HTTP/1.1 uses text messages, persistent connections and (rarely) pipelining. HTTP/2 uses binary frames, header compression and many streams on one TCP connection. HTTP/3 runs the same semantics over QUIC on UDP. See HTTP/1.1, HTTP/2 and HTTP/3.

43. Which HTTP methods are idempotent? GET, HEAD, PUT, DELETE and OPTIONS. POST and PATCH are not guaranteed to be, so a retry could repeat a side effect.

44. Explain common status codes. 200 OK, 201 Created, 204 No Content, 301 Moved Permanently, 302/307 temporary redirects, 304 Not Modified, 400 Bad Request, 401 not authenticated, 403 not allowed, 404 Not Found, 429 Too Many Requests, 500 server error, 502 bad gateway (bad answer from upstream), 503 unavailable, 504 gateway timeout.

45. How do cookies and caching work? A server sets a cookie with Set-Cookie; the browser returns it with later requests to that site to add state to a stateless protocol. Caching uses Cache-Control, ETag and conditional requests (If-None-Match) so unchanged content costs only a 304. See Caching, Cookies and State.

Security and operations

46. How does TLS protect a connection? It authenticates the server with a certificate chain, agrees on a shared key using an ephemeral key exchange (giving forward secrecy), and then encrypts and authenticates the data. TLS 1.3 completes the handshake in one round trip. See TLS and HTTPS.

47. Stateless versus stateful firewall? A stateless filter judges each packet alone against rules. A stateful firewall tracks connections, so it can allow replies to outbound traffic and drop unsolicited packets. See Firewalls, VPNs and Intrusion Detection.

48. A website will not load. How do you troubleshoot? Work up the layers. Check the link and IP configuration, ping the gateway, ping a public IP, resolve a name with a DNS lookup, then test the port with a TCP connection and request the page with curl. The first step that fails shows the layer to blame. See Troubleshooting Network Problems.

Deeper questions for experienced roles

Senior interviews go beyond definitions. These answers are short on purpose; they are the first minute of an answer, which you then support with an example.

49. How does Nyquist's theorem differ from Shannon's capacity theorem? Nyquist gives the maximum symbol rate of a noiseless channel: 2 x bandwidth samples per second, so with L signal levels the bit rate is 2 x B x log2(L). Shannon gives the maximum error-free rate of a noisy channel: B x log2(1 + SNR), no matter how many levels you use. Nyquist tells you what more levels could do; Shannon tells you where noise stops you.

50. Full duplex or half duplex at the physical layer: what is hard about full duplex? Both directions are used at once, so you need separate paths (two wire pairs, two fibers, or two frequency bands) or echo cancellation on one pair, as gigabit Ethernet does. The challenge is that the device's own transmitter is much louder than the far end's signal, so it must be cancelled, which needs more processing and power.

51. Analog or digital modulation? Analog modulation varies a carrier continuously with an analog message (AM and FM radio). Digital modulation maps bits to discrete changes of amplitude, frequency, phase or a combination (ASK, FSK, PSK, QAM). Digital is more resistant to noise, can be regenerated and encrypted, and is used in Wi-Fi, cellular and cable.

52. What is baseband versus broadband, and when is baseband preferable? Baseband uses the whole bandwidth of the medium for one signal (Ethernet), broadband splits it into several channels (cable TV, DSL). Baseband is simpler and cheaper and is preferable for short distances, a single service and digital LANs.

53. What does MIMO bring to Wi-Fi? Several antennas allow spatial multiplexing (different data streams sent at once on the same frequency, which multiplies the data rate) and diversity gain (several copies of a signal over different paths reduce fading, which improves reliability). Wi-Fi 4 introduced it, and Wi-Fi 5 and 6 added multi-user versions.

54. How does route redistribution work, and what problems can it introduce? A router copies routes from one routing protocol into another, assigning a metric because the two metrics are not comparable. Problems are routing loops (two redistribution points feeding each other), suboptimal paths and lost information. Use route tags and filters, redistribute at as few points as possible, and set metrics deliberately.

55. What is policy-based routing and when would you use it? Forwarding decided by policy (source address, protocol, port) instead of only the destination. Use it to send guest traffic out a cheaper link or voice traffic over the low-latency one. It is harder to troubleshoot, because the path no longer matches the routing table.

56. What is BGP route dampening, and what is SPF throttling? Dampening penalizes prefixes that flap and hides them until the penalty decays. SPF throttling delays and spaces OSPF or IS-IS shortest-path recalculations so that an unstable link cannot make routers run the algorithm constantly.

57. What is VLAN trunking? One physical link carries frames of many VLANs, each tagged with an 802.1Q header holding a 12-bit VLAN ID (so at most 4094 usable VLANs). Switches use trunks between them, and the untagged "native VLAN" must be handled carefully to avoid VLAN-hopping attacks.

58. Flow control or congestion control? Flow control is receiver-side: the receiver's advertised window stops a fast sender from overrunning a slow receiver. Congestion control is network-side: the sender reduces its rate when the path is overloaded, using signals such as loss and delay. TCP applies both, and sends at the minimum of the two windows.

59. What are the limits of HTTP/1.1 and what did HTTP/2 improve? HTTP/1.1 handles one request at a time per connection (head-of-line blocking), so browsers open many connections and use workarounds, and its headers are repeated as text. HTTP/2 multiplexes streams over one connection, compresses headers (HPACK) and can push resources. TCP-level head-of-line blocking remains, which is why HTTP/3 uses QUIC.

60. What role does TLS play on top of TCP? It adds confidentiality, integrity and authentication of the server (and optionally the client), without changing the application protocol: HTTP over TLS is HTTPS. It sits between the transport and application layers.

Check the arithmetic questions yourself

The two editors below cover questions 18 to 21: block sizes, host counts, address types and longest-prefix match.

Python Subnetting answers on demand

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A /26 holds 64 addresses; 192.168.10.77 sits in the block from .64 to .127, so the network address is 192.168.10.64 and the broadcast is 192.168.10.127. Each extra host bit doubles the size of the block.

Python Address types and longest-prefix match

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that 172.32.0.1 is public: the private block 172.16.0.0/12 stops at 172.31.255.255. The interview habit of "172.something is private" is a classic trap. The script labels 100.64.1.1 "shared or reserved": that range is neither private (RFC 1918) nor globally routable, because it is set aside for carrier-grade NAT.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which device separates broadcast domains by default?

    Routers do not forward layer 2 broadcasts. Hubs, repeaters and an unsegmented switch pass them on to every port.
  2. 2. A host has 40 TCP connections stuck in CLOSE_WAIT. What is the most likely cause?

    CLOSE_WAIT means the peer sent FIN and the local side has not yet closed. The kernel is waiting for the application to call close.
  3. 3. Which pair of statements about TCP and UDP is correct?

    TCP's header is at least 20 bytes and UDP's is 8. TCP offers reliability, ordering, flow and congestion control; UDP offers none of these.
  4. 4. A 502 response usually means:

    502 Bad Gateway is produced by a proxy or gateway when the server behind it fails or answers badly. 504 is the timeout variant.
  5. 5. Two routes match 10.20.30.40: 10.0.0.0/8 and 10.20.0.0/16. Which is used?

    Routers choose the most specific matching route: the one with the longest prefix length.

Summary

  • Answer in a pattern: layer, mechanism, trade-off. Use numbers when you have them (64 addresses in a /26, three duplicate ACKs, 2 ร— MSL).
  • Know the layer boundaries: switches use MAC addresses, routers use IP addresses, TCP and UDP use ports, applications use names.
  • Be able to explain the handshake, reliability, flow control and congestion control without notes; they come up in nearly every interview.
  • Subnetting and address-type questions are arithmetic. Practice until the powers of two are automatic.
  • For troubleshooting questions, walk the layers from the bottom and say what each test proves.

Next: Computer Networks Cheat Sheet