Computer networks interview questions: TCP, DNS, HTTP and TLS

Computer networks interview questions for software engineers focus on how data gets from one program to another: the TCP/IP layers, TCP versus UDP, the three-way handshake, congestion control, DNS resolution, HTTP versions and TLS. The favorite single question is "what happens when you type a URL and press Enter", because it touches every layer. Answer from the developer's side, connecting each protocol detail to latency, reliability or a bug you could actually see.

By Published 10 min read

How networking questions appear in software interviews

Campus placements treat computer networks as a core subject next to operating systems and DBMS, with definition and comparison questions about layers and protocols. Backend, full stack, mobile and SRE interviews ask the same material through symptoms: requests that time out only from one region, a service that runs out of ports, a page that loads slowly despite a fast server, a certificate error after a deploy. Expect to explain one protocol in depth, compare two, and trace a request end to end. Subnetting by hand appears in some rounds, though rarely at the depth of a network engineering interview.

Layers and models

OSI and TCP/IP, with what a developer meets at each layer
OSI layerTCP/IP layerExamplesWhat you debug there
7 Application, 6 Presentation, 5 SessionApplicationHTTP, DNS, TLS (often placed here), SMTP, gRPCStatus codes, headers, payload formats, certificates
4 TransportTransportTCP, UDP, QUIC (over UDP)Ports, connection resets, timeouts, retransmissions
3 NetworkInternetIPv4, IPv6, ICMPRouting, unreachable hosts, MTU problems
2 Data linkLinkEthernet, Wi-Fi, ARPLocal network issues, rarely an app developer's job
1 PhysicalLinkCables, radioNot usually in software interviews
OSI and TCP/IP, with what a developer meets at each layer. Scroll sideways on a small screen.
  • Why do we use layers at all? Each layer offers a service to the one above and hides how it works, so HTTP does not care whether packets travel over Wi-Fi or fiber. Mention that real protocols blur the OSI lines (TLS and QUIC do not fit neatly).
  • What is encapsulation? Each layer wraps the data from above with its own header: an HTTP message inside a TCP segment inside an IP packet inside an Ethernet frame.
  • What is the difference between a port and an IP address? The IP address finds the host; the port finds the process on it. A TCP connection is identified by the four-tuple of source IP, source port, destination IP and destination port.
  • What is MTU and why does it matter? The largest packet a link carries without fragmentation, commonly 1,500 bytes on Ethernet. VPNs and tunnels shrink it, and broken path MTU discovery causes connections that hang only on large responses.

TCP and UDP

Transport questions
QuestionWhat it testsWhat a strong answer shows
TCP versus UDP: when would you use each?Trade-offsTCP for anything that must arrive complete and in order (web pages, APIs, file transfer). UDP for latency-sensitive data where late is useless (voice, games, live video) or where the application builds its own reliability, as QUIC does.
Walk through the three-way handshake.Connection setupClient sends SYN with its initial sequence number, server replies SYN-ACK with its own, client sends ACK. It costs one round trip before data, which is why connection reuse matters.
How is a TCP connection closed, and what is TIME_WAIT?TeardownEach side sends FIN and gets an ACK. The side that closes first waits in TIME_WAIT (twice the maximum segment lifetime) so stray old packets do not confuse a new connection on the same four-tuple. Lots of short outbound connections can pile up TIME_WAIT sockets and exhaust ports.
How does TCP make delivery reliable?MechanismSequence numbers, acknowledgments, retransmission after a timeout or after duplicate ACKs, and checksums. The receiver reorders segments before handing bytes to the application.
Flow control versus congestion control?PrecisionFlow control protects the receiver: the advertised window says how much it can buffer. Congestion control protects the network: the sender's congestion window grows and shrinks with perceived loss or delay.
Explain slow start and AIMD.Congestion controlA new connection starts with a small congestion window and roughly doubles it each round trip until loss or a threshold. Then it grows additively and halves on loss. Newer algorithms such as CUBIC and BBR change the curve but keep the goal.
What is head-of-line blocking in TCP?PerformanceOne lost segment holds back every later byte until it is retransmitted, even bytes belonging to unrelated requests sharing the connection.
What does Nagle's algorithm do and why disable it?LatencyIt batches small writes until earlier data is acknowledged. Combined with delayed ACKs it can add noticeable delay to small request-response messages, so latency-sensitive apps set TCP_NODELAY.
What does a connection reset (RST) mean?DebuggingThe other side refused or abandoned the connection: nothing listening on the port, the process crashed, or a load balancer or firewall dropped idle state.
Why keep connections alive and pooled?PracticalEach new connection costs a TCP handshake plus a TLS handshake. Pooling keeps warm connections with grown congestion windows, which cuts latency noticeably for chatty services.
Transport questions. Scroll sideways on a small screen.
import socket
import threading

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(("127.0.0.1", 0))           # port 0: let the OS pick a free port
server.listen()
port = server.getsockname()[1]


def serve_one():
    conn, _ = server.accept()
    with conn:
        while data := conn.recv(1024):
            conn.sendall(data.upper())


threading.Thread(target=serve_one, daemon=True).start()

message = b"hello over tcp"
with socket.create_connection(("127.0.0.1", port)) as client:
    client.sendall(message)
    received = b""
    while len(received) < len(message):   # one send can arrive as several recvs
        received += client.recv(1024)
print(received.decode())  # HELLO OVER TCP
A TCP echo server and client on localhost. TCP delivers a byte stream, not messages, so the client loops until it has read as many bytes as it sent.

IP addressing, NAT and the local network

  • What does /24 mean in 192.168.1.0/24? The first 24 bits are the network part, leaving 8 bits for hosts: 256 addresses, of which 254 are usable in a traditional IPv4 subnet because the network and broadcast addresses are reserved.
  • What are private IP ranges and NAT? 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are not routed on the public internet. NAT on a router rewrites private source addresses and ports to its public address, which is why servers behind NAT cannot be reached without port forwarding.
  • Why IPv6? IPv4's roughly 4.3 billion addresses ran out. IPv6 has 128-bit addresses, removes the need for NAT in principle, and changes how hosts configure themselves. Many services run dual stack.
  • What do ARP and DHCP do? ARP finds the MAC address for an IP on the local network. DHCP hands a joining device its IP address, gateway and DNS servers.
  • What is the difference between a hub, a switch and a router? A switch forwards frames within a network by MAC address; a router forwards packets between networks by IP address. Hubs, which repeat everything to every port, are mostly history.
import ipaddress

net = ipaddress.ip_network("10.20.0.0/22")
hosts = list(net.hosts())
print(net.num_addresses, hosts[0], hosts[-1], net.broadcast_address)
# 1024 10.20.0.1 10.20.3.254 10.20.3.255

print([str(s) for s in net.subnets(new_prefix=24)])
# ['10.20.0.0/24', '10.20.1.0/24', '10.20.2.0/24', '10.20.3.0/24']

print(ipaddress.ip_address("172.20.5.9").is_private)  # True
Subnet arithmetic with the standard library, handy for checking hand calculations.

DNS

DNS questions
QuestionWhat it testsWhat a strong answer shows
How does a DNS lookup work?Resolution pathThe OS checks its cache and hosts file, then asks a recursive resolver. On a cache miss the resolver asks a root server, then the TLD server (.com), then the domain's authoritative server, caching each answer for its TTL.
Recursive versus iterative queries?VocabularyThe client asks the resolver to do all the work (recursive). The resolver then asks each server in turn, which only refers it onward (iterative).
Name common record types.RecordsA (IPv4), AAAA (IPv6), CNAME (alias), MX (mail), NS (delegation), TXT (verification and email policy), SRV (service location).
Why can a DNS change take hours to show up everywhere?CachingResolvers and clients cache the old answer until its TTL expires. Lower the TTL well before a planned migration.
Why can't a CNAME sit at the root of a domain?Spec detailA CNAME cannot coexist with other records for the same name, and the zone apex must have SOA and NS records. Providers offer alias or flattening features to work around it.
Does DNS use UDP or TCP?TransportMostly UDP on port 53 for small queries, with TCP for large responses and zone transfers. Encrypted variants such as DNS over HTTPS and DNS over TLS also exist.
How is DNS used for load balancing and failover?PracticalMultiple A records, weighted or latency-based answers and health-checked failover. Caching makes it coarse, so it is paired with load balancers.
DNS questions. Scroll sideways on a small screen.

HTTP/1.1, HTTP/2 and HTTP/3

HTTP versions compared
VersionTransportKey ideasWeak spot
HTTP/1.1TCPText format, persistent keep-alive connections, one request at a time per connection in practice, so browsers open several connections per hostSlow responses block the connection; many connections cost handshakes
HTTP/2TCP (with TLS in browsers)Binary framing, many concurrent streams over one connection, header compression (HPACK), stream prioritiesA lost TCP segment stalls every stream (TCP head-of-line blocking)
HTTP/3QUIC over UDPStreams handled by QUIC so loss on one does not stall others, TLS 1.3 built in, faster setup, connections that survive a network changeUDP can be blocked or throttled on some networks, so clients fall back to HTTP/2
HTTP versions compared. Scroll sideways on a small screen.
  • What makes a method safe or idempotent? Safe methods (GET, HEAD) do not change state. Idempotent methods (GET, PUT, DELETE) give the same result when repeated, which is what makes retries safe. POST is neither by default.
  • 401 versus 403, and 502 versus 504? 401 means not authenticated, 403 means authenticated but not allowed. 502 means the gateway got a bad response from upstream; 504 means the upstream did not answer in time.
  • How does HTTP caching work? Cache-Control sets freshness (max-age, no-store, private). ETag and Last-Modified let a client revalidate with a conditional request and get a short 304 Not Modified instead of the full body.
  • What is CORS and who enforces it? The browser enforces it. A page's script may only read responses from another origin if that server allows it with Access-Control-Allow-Origin; non-simple requests send a preflight OPTIONS first. It does not protect the server from non-browser clients.
  • WebSockets versus long polling versus server-sent events? WebSockets upgrade an HTTP connection to a full-duplex channel. Server-sent events stream server-to-client over plain HTTP. Long polling holds a request open until there is news and works everywhere.
  • Layer 4 versus layer 7 load balancer? Layer 4 balances TCP or UDP connections without reading them. Layer 7 understands HTTP, so it can route by path or header, terminate TLS and retry, at more cost per request.
GET /index.html HTTP/1.1
Host: example.com
User-Agent: demo-client/1.0
Accept: text/html
Connection: keep-alive

A raw HTTP/1.1 request as it travels over the connection. On the wire each line ends with a carriage return and line feed, the Host header is required in HTTP/1.1, and a blank line ends the headers.

TLS and HTTPS

  • What does TLS provide? Confidentiality (encryption), integrity (tampering is detected) and authentication of the server, and optionally the client, through certificates.
  • Walk through a TLS 1.3 handshake. The client sends supported cipher suites and a key share; the server picks one, sends its key share, certificate and a signature proving it holds the private key, and both derive session keys. That takes one round trip, one fewer than TLS 1.2's full handshake.
  • How does the browser trust a certificate? It checks that the certificate covers the hostname, is within its validity dates, is not revoked, and chains up through intermediates to a root certificate authority in its trust store.
  • What is SNI? Server Name Indication: the client names the host it wants during the handshake so one IP address can serve certificates for many domains.
  • Symmetric or asymmetric encryption in TLS? Asymmetric cryptography authenticates and agrees on keys; the bulk data is encrypted with fast symmetric ciphers such as AES-GCM or ChaCha20-Poly1305.
  • What is the risk of 0-RTT resumption? Early data sent in the first flight can be replayed by an attacker, so it should only carry idempotent requests.
  • What is forward secrecy? Session keys come from ephemeral key exchanges, so stealing the server's private key later does not decrypt recorded past traffic. TLS 1.3 requires it.

What happens when you type a URL and press Enter

  1. Parse and check cachesThe browser parses the URL, may upgrade to HTTPS if the site uses HSTS, and checks whether it already has a usable cached response or an open connection to that origin.
  2. Resolve the nameBrowser and OS DNS caches first, then the recursive resolver, which walks root, TLD and authoritative servers if needed. The result is one or more IP addresses.
  3. ConnectA TCP handshake (or a QUIC handshake for HTTP/3), then the TLS handshake with certificate validation. ALPN during TLS agrees on HTTP/2 or HTTP/1.1.
  4. Send the requestThe browser sends the GET with headers and cookies for that origin. It may pass through a CDN edge, a load balancer and a reverse proxy before reaching an application server.
  5. Server workThe application authenticates the request, reads caches or databases and builds the response with a status code, headers and body, often compressed.
  6. RenderThe browser parses HTML into the DOM, fetches CSS, scripts and images (reusing the connection), builds the render tree, lays out and paints. Scripts can block parsing unless they are deferred or async.

Senior and scenario questions

Symptom questions and the layer to check first
QuestionWhat it testsWhat a strong answer shows
Requests to one partner API fail with timeouts, but only from production.IsolationCompare DNS answers, outbound firewall or egress rules, and whether production goes through a NAT gateway or proxy with a different IP that the partner has not allowed.
A service makes many short outbound HTTP calls and starts failing to connect.Port exhaustionEphemeral ports stuck in TIME_WAIT from opening a new connection per request. Reuse connections with a pool and keep-alive.
Small API responses are fast, but large ones hang over the VPN.MTUPackets above the tunnel's MTU are dropped and the ICMP messages needed for path MTU discovery are blocked. Lower the MTU or allow the ICMP messages.
After a certificate renewal, some clients fail the TLS handshake.Certificate chainThe server is probably sending an incomplete chain, missing an intermediate, and only clients that cached it succeed. Serve the full chain.
Users report the site down while your health checks pass.Vantage pointCheck DNS from outside your network, the CDN and load balancer status, and certificate validity, since internal checks often skip all three.
WebSocket connections drop every few minutes.Idle timeoutsA proxy or load balancer closes idle connections. Send application-level pings more often than the shortest idle timeout on the path.
Symptom questions and the layer to check first. Scroll sideways on a small screen.

Fictional example

Answering "Our API is fast in the data center but slow for users in another region"
Interviewer
Server-side timing says each request takes 40 ms, but users far away see over a second for the first request. Why?
Candidate
Server time does not include the network. For a first request from far away, the client pays a DNS lookup, then a TCP handshake round trip, then a TLS handshake round trip, then the request and response, and each round trip to a distant region costs a lot of latency. Large responses also need several more round trips while TCP's congestion window grows from slow start. I would measure with browser timing or a curl write-out format to split DNS, connect, TLS and time to first byte. Fixes, depending on what dominates: terminate TLS at a CDN or regional edge close to users, keep connections alive and pooled, enable HTTP/2 or HTTP/3, cache cacheable responses at the edge, cut the number of round trips the client makes, and compress responses. If most of the cost is the first request only, connection reuse alone may fix what users notice.

How to prepare for networking questions

  1. Own the URL walk-throughPractice it at three lengths: one minute, five minutes, and as deep as the interviewer wants on any single step. It is the most common networking question.
  2. Watch real trafficUse your browser's network panel, curl -v, dig and a packet capture tool once. Seeing a handshake, a DNS answer and response headers makes your answers concrete.
  3. Learn TCP in detailHandshake, teardown, TIME_WAIT, retransmission, flow versus congestion control and head-of-line blocking. Interviewers dig deepest here.
  4. Compare the HTTP versionsBe able to say what each version fixed and what problem it left. Then add TLS 1.3 and what HTTPS really guarantees.
  5. Practice symptom questionsTimeouts, resets, certificate errors, slow first requests, port exhaustion. For each, name the layer and the tool you would use to confirm.

Networking ties into several other topics. OAuth and JWT interview questions builds on TLS and HTTP to cover authentication and tokens, operating system interview questions covers sockets, file descriptors and epoll on the host, and Kafka interview questions shows a protocol built on TCP for streaming. For architecture questions, read caching in system design and the backend developer interview questions page.

Networking answers tend to sprawl, so rehearse them with a clock and a record. Natively is an AI interview assistant for Mac and Windows that transcribes a mock round while you walk through a request, can draft an answer you can compare against your own, and reads a diagram or question from a screenshot. On Pro or the free trial it also uses the résumé and job description you add, and the transcript and notes are saved so you can see which layer you skipped.

Questions people ask

What networking questions are asked in software engineer interviews?

OSI and TCP/IP layers, TCP versus UDP, the three-way handshake, DNS resolution, HTTP versions, TLS and HTTPS, and above all what happens when you type a URL and press Enter.

What is the difference between TCP and UDP?

TCP is connection-based and delivers an ordered, reliable byte stream with flow and congestion control. UDP sends independent datagrams with no delivery or ordering guarantees and very little overhead.

How does DNS resolution work?

The client checks local caches, then asks a recursive resolver. On a miss, the resolver asks a root server, then the top-level domain server, then the domain's authoritative server, caching answers for their TTL.

What is the difference between HTTP/2 and HTTP/3?

HTTP/2 multiplexes many streams over one TCP connection, so one lost packet stalls them all. HTTP/3 runs over QUIC on UDP, where loss on one stream does not block the others, and TLS 1.3 is built in.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP