Computer Networks Interview Questions and Answers

OSI and TCP/IP, HTTP, DNS, routing, TLS and troubleshooting.

Practise 10 random 7 peer-reviewed questions
Computer Networks Interview Syllabus & Preparation Strategy

Whether you are preparing for entry-level Computer Networks interview questions for freshers or senior software engineer interview questions addressing concurrency, scalability, and system architecture, this track provides peer-reviewed model answers with syntax walkthroughs, edge cases, and practical interview tips.

1 Describe how DNS resolution works. Medium

DNS maps names to records, most importantly A and AAAA addresses, plus CNAME, MX, TXT and NS. A lookup can walk several servers, but caching means most lookups stop early.

Resolution steps:

  1. Check the local hosts file and OS resolver cache.
  2. Query the configured recursive resolver, often via the ISP or a public service.
  3. If not cached, the resolver asks a root server, which points to the top-level domain servers.
  4. The TLD server points to the domain's authoritative name servers.
  5. The authoritative server returns the record; the resolver caches it for its TTL and answers the client.

Queries use UDP port 53, falling back to TCP for large responses, and DoT or DoH when encryption is wanted.

client -> recursive resolver -> root -> .com -> ns.example.com

Caching and TTLs reduce load and latency. Debug with dig +trace or nslookup, and remember that propagation delays are really cache expiry.

2 Explain the TLS handshake and what it protects. Medium

TLS provides confidentiality, integrity and authentication for a connection. In TLS 1.3 the handshake is one round trip before application data.

  1. The client sends a ClientHello with supported versions, cipher suites, a key share for ECDHE and a random nonce.
  2. The server replies with ServerHello, its own key share, selects parameters, and sends a certificate proving its identity.
  3. The client verifies the certificate chain up to a trusted root CA, checks the hostname and validity, and both sides derive the shared session key from the ECDHE exchange.
  4. The client sends Finished, the server confirms, and encrypted records flow.
ClientHello -> <- ServerHello + Cert; derive keys; Finished

Key points: ECDHE gives forward secrecy, so a stolen private key cannot decrypt recorded sessions; certificates bind a public key to a name; and session resumption or 0-RTT trades some security for latency. TLS 1.2 needed two round trips, one reason 1.3 is faster.

3 Explain subnetting and CIDR notation. Medium

An IP address is split into a network part and a host part by the subnet mask, which can be written as a CIDR prefix. /24 means the first 24 bits are the network, leaving 8 host bits.

192.168.1.0/24
mask  255.255.255.0
network 192.168.1.0   broadcast 192.168.1.255
usable hosts 192.168.1.1 - 192.168.1.254  (254 hosts)

The number of addresses is 2^(32-prefix), and usable hosts are that minus the network and broadcast addresses for IPv4. Borrowing bits creates subnets; splitting a /24 into four /26 gives 62 usable hosts each.

Longest-prefix match means a router forwarding a packet picks the most specific route. CIDR replaced classful addressing and allows route aggregation, so many contiguous networks are advertised as a single summary route. Private ranges such as 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are not routed on the public Internet.

4 Walk through the TCP three-way handshake and connection teardown. Medium

TCP opens a connection with a three-way handshake so both sides agree on initial sequence numbers and confirm they can send and receive.

  1. Client sends SYN with its initial sequence number and options such as MSS and window scaling.
  2. Server replies SYN-ACK: it acknowledges the client's sequence number and sends its own SYN.
  3. Client sends ACK acknowledging the server's sequence number; the connection is established.
Client          Server
  SYN seq=x  ->
             <- SYN-ACK seq=y ack=x+1
  ACK ack=y+1 ->

Two steps would not be enough: each side needs to know the other received its SYN, and the exchange prevents stale duplicates from an old connection being mistaken for a new one. Sequence numbers are randomised to make blind spoofing hard.

Teardown takes four steps, FIN, ACK, FIN, ACK, because each direction closes independently, and the side that closes last waits in TIME_WAIT to absorb delayed segments.

5 What is the difference between routing and switching? Medium

Switching and routing both forward packets, but at different layers and scopes.

A switch works at layer 2 using MAC addresses within a single broadcast domain, the LAN. It learns which MAC is reachable on which port by inspecting source addresses and forwards frames only to the correct port, flooding unknown destinations. VLANs segment one physical switch into logical LANs.

A router works at layer 3 using IP addresses and moves packets between networks. It consults a routing table built from directly connected networks, static routes and dynamic protocols such as OSPF, EIGRP or BGP, and picks the longest matching prefix. It also decrements the TTL and can perform NAT.

host -> switch (MAC) -> router (IP) -> internet

Routers break broadcast domains and connect dissimilar networks; switches are faster and cheaper but confined to the local segment. Layer 3 switches combine both functions.

6 What is NAT and what problems does it cause? Medium

Network Address Translation rewrites IP addresses and often ports as packets cross between a private network and the public Internet. It exists mainly because IPv4 addresses are scarce.

A home router has one public address and gives private addresses such as 192.168.1.x to devices. When an inside host opens a connection, the router replaces the source address and port with its public address and a chosen port, and records the mapping. Replies matching that mapping are translated back.

10.0.0.5:52000 -> 203.0.113.7:40001 -> server
mapping table keeps the reverse path

Types include static NAT, dynamic NAT and PAT or masquerading, which multiplexes many hosts over one address. NAT conserves addresses and hides internal topology, but it breaks end-to-end connectivity, complicates peer-to-peer and burdens the device with state. It also motivates STUN, TURN and hole punching. IPv6 removes the need.

7 How do you troubleshoot a network problem methodically? Medium

Network troubleshooting is easier when you reason up the layers and use the right tool at each step.

  • ping checks reachability and round-trip time using ICMP and reveals packet loss.
  • traceroute shows the path and where latency or loss begins.
  • dig or nslookup verifies DNS records and which server answered.
  • ss or netstat lists listening sockets and established connections.
  • curl -v inspects HTTP status, headers and TLS negotiation.
  • tcpdump or Wireshark captures packets to confirm what is on the wire.
  • ip addr and ip route verify local addressing and routing.
dig example.com +short
curl -v https://example.com
ss -tulpn

A sensible order is name resolution, then local interface and route, then reachability, then port and application. Check firewalls and security groups early too, since a silent timeout often means a dropped packet rather than a dead host.

Frequently Asked Questions About Computer Networks Interviews

What do hiring managers evaluate in Computer Networks technical rounds?

Technical interviewers look for foundational fluency, idiomatic syntax, clarity when communicating complex logic, and awareness of performance trade-offs (e.g. memory footprint, render performance, and network latency) in production environments.

What are the best interview tips for practicing Computer Networks questions?

Use active recall: summarize each answer in your own words before revealing the model solution. Focus on explaining why a certain approach is chosen rather than just memorizing code syntax.