Top 50 Computer Networks Interview Questions (2026)

The 50 computer networks questions interviewers actually ask, with direct answers, protocol details, layered-model comparisons, and what the interviewer is listening for. Grouped for freshers, intermediate, and experienced rounds.

50 questions with answers

What Is Computer Networks?

Key Takeaways

  • Computer networks is the study of how devices and exchange data, from the physical wire up connects to the application protocols you use every day.
  • The mental backbone is a layered model: OSI's seven layers for teaching, the four-layer TCP/IP stack for what actually runs the internet.
  • Interviews test whether you can trace a packet end to end: what happens when you type a URL, how TCP differs from UDP, why DNS and ARP exist.
  • This page is a question bank: work your tier first, read one tier up, and say answers out loud because delivery and reasoning are evaluated too.

Computer networks is the branch of computer science that deals with how devices talk to each other and move data reliably across links, from a cable between two machines to the global internet. It's built on layered thinking: each layer solves one job and hands off to the next, so the physical medium, the way bytes get framed and addressed, how packets are routed, how a connection stays reliable, and how applications like the web and email speak are all separable concerns. The OSI model gives you seven layers for reasoning and teaching; the TCP/IP model gives you the four layers that the real internet runs on. In interviews, networking questions probe whether you can trace what actually happens: what occurs when you type a URL and hit enter, why TCP is reliable and UDP isn't, how DNS turns a name into an address, and what a subnet mask really does. The MDN overview of HTTP is a solid canonical reference for the application-layer half of that story. This page collects the 50 questions that come up most, each with a direct answer plus the protocol detail an interviewer expects; pair it with our AI interview preparation guides for the live-round format, since the first technical screen is increasingly an AI-driven one.

50Questions with answers on this page
3Difficulty tiers: freshers, intermediate, experienced
7OSI layers you're expected to explain
30-45 minTypical length of a networking technical round

Watch: Computer Networking in 100 Seconds

Video: Computer Networking in 100 Seconds (Fireship, YouTube)

Test yourself and earn a certificate

10 quick questions. Score 70%+ to download your Computer Networks certificate.

Jump to quiz

All Questions on This Page

50 questions
Computer Networks Interview Questions for Freshers
  1. 1. What is a computer network?
  2. 2. What are LAN, MAN, and WAN?
  3. 3. What are the seven layers of the OSI model?
  4. 4. What is the difference between the OSI model and the TCP/IP model?
  5. 5. What is the difference between TCP and UDP?
  6. 6. What is an IP address, and how do IPv4 and IPv6 differ?
  7. 7. What is the difference between a public and a private IP address?
  8. 8. What is a subnet mask and what does it do?
  9. 9. What is DNS and why is it needed?
  10. 10. What is DHCP and what does it do?
  11. 11. What is the difference between HTTP and HTTPS?
  12. 12. What is the difference between a hub, a switch, and a router?
  13. 13. What is the difference between a MAC address and an IP address?
  14. 14. What is a network protocol?
  15. 15. What is the difference between a packet, a frame, and a segment?
  16. 16. What is the difference between bandwidth and latency?
  17. 17. What are the common network topologies?
  18. 18. What is the difference between unicast, broadcast, and multicast?
  19. 19. Which protocols live at which OSI layer?
Computer Networks Intermediate Interview Questions
  1. 20. Explain the TCP three-way handshake.
  2. 21. How does subnetting work, and why do we subnet?
  3. 22. Walk through what happens during a DNS lookup.
  4. 23. What happens when you type a URL into a browser and press enter?
  5. 24. What is NAT and why is it used?
  6. 25. What is the difference between flow control and congestion control in TCP?
  7. 26. How does a router decide where to send a packet?
  8. 27. What is the difference between OSPF and BGP?
  9. 28. What are ports and sockets?
  10. 29. Which well-known ports and their protocols should you know?
  11. 30. How do the TCP and UDP headers differ, and why?
  12. 31. What is ICMP, and how do ping and traceroute use it?
  13. 32. How does ARP work?
  14. 33. What is the difference between a collision domain and a broadcast domain?
  15. 34. What happens during a TLS handshake?
  16. 35. How do HTTP cookies keep a stateless protocol stateful?
  17. 36. What is the difference between HTTP GET and POST?
Computer Networks Interview Questions for Experienced Engineers
  1. 37. How does TCP congestion control actually work?
  2. 38. What are the differences between HTTP/1.1, HTTP/2, and HTTP/3?
  3. 39. How does load balancing work, and what's the difference between L4 and L7?
  4. 40. How does a CDN work, and what problems does it solve?
  5. 41. How do firewalls work, and what are stateful vs stateless firewalls?
  6. 42. How does a VPN work?
  7. 43. What are the main DNS record types and what do they do?
  8. 44. What are common network attacks and how do you defend against them?
  9. 45. What is QUIC and why was it created?
  10. 46. How do you reduce latency in a networked application?
  11. 47. How does socket programming work at a high level?
  12. 48. Design question: how would you architect a service to handle millions of concurrent connections?
  13. 49. How do WebSockets differ from HTTP, and when do you use them?
  14. 50. Walk me through how you'd diagnose a 'website won't load' problem.

Computer Networks Interview Questions for Freshers

Freshers19 questions

The fundamentals every entry-level round checks: the layered models, TCP vs UDP, IP addressing, DNS, and the basic devices. If any answer here surprises you, that's your study list.

Q1. What is a computer network?

A computer network is a set of devices connected so they can share data and resources. The connection can be wired or wireless, and the devices range from two laptops to millions of machines on the internet.

Networks let devices exchange messages, share files and printers, and reach services like websites and email. They're organized in layers so each concern, the physical link, addressing, routing, and the application, can be handled separately.

Key point: Keep the opening answer plain and correct. Interviewers use it to check you can define a concept cleanly before they go deeper.

Watch a deeper explanation

Video: Computer Networking Course: Network Engineering (CompTIA Network+ Exam Prep) (freeCodeCamp.org, YouTube)

Q2. What are LAN, MAN, and WAN?

They're networks classified by geographic size. A LAN (Local Area Network) covers a small area like a home, office, or building. A MAN (Metropolitan Area Network) spans a city or campus. A WAN (Wide Area Network) covers large distances, potentially countries; the internet is the largest WAN.

The practical difference is scale and ownership: a LAN is usually owned by one organization and is fast and cheap over short distances, while a WAN links separate networks over long distances, often over links you lease rather than own.

TypeScopeTypical example
LANOne building or officeHome or office network
MANA city or large campusCity-wide fiber network
WANCountries or the globeThe internet

Key point: Anchor each one to size and a real example, and call the internet the biggest WAN. That concrete mapping is all this warm-up question is checking.

Q3. What are the seven layers of the OSI model?

From bottom to top the seven layers are physical, data link, network, transport, session, presentation, and application. Each layer handles one job and passes data to the next, so a change at one layer doesn't force changes everywhere else and each can be reasoned about on its own.

Physical moves raw bits, data link frames them and handles MAC addressing, network routes packets by IP, transport gives end-to-end delivery (TCP or UDP), session manages dialogs, presentation handles formatting and encryption, and application is where protocols like HTTP live.

  • Physical: raw bits over a medium (cables, radio).
  • Data link: frames and MAC addresses; switches live here.
  • Network: packets and IP addresses; routers live here.
  • Transport: end-to-end delivery via TCP or UDP.
  • Session, presentation, application: dialogs, formatting/encryption, and the app protocol.

Key point: Don't just recite the names. Naming one job and one protocol per layer is what convinces the interviewer you understand the model, not a mnemonic.

Watch a deeper explanation

Video: OSI Model Explained: Open System Interconnection, the 7 layers (TechTerms, YouTube)

Q4. What is the difference between the OSI model and the TCP/IP model?

OSI is a seven-layer reference model built for teaching and for reasoning about where a problem lives. TCP/IP is a four-layer model that the actual internet runs on, so it maps directly to real protocols.

TCP/IP combines OSI's physical and data link into one link layer, and it merges session, presentation, and application into a single application layer. Use OSI to explain and locate problems; TCP/IP is the stack that's really implemented.

OSITCP/IP
Layers74
RoleReference and teachingReal internet stack
Application side3 layers1 combined layer

Key point: Say 'OSI is the map, TCP/IP is the terrain'. That one line shows you understand why both models exist.

Q5. What is the difference between TCP and UDP?

TCP is connection-oriented and reliable: it sets up a connection with a handshake, numbers and acknowledges bytes, retransmits what's lost, and delivers data in order. That reliability adds overhead and latency, since every segment has to be tracked and confirmed before the stream is considered complete.

UDP is connectionless and unreliable by design: it just sends datagrams with no handshake, no acknowledgment, and no ordering. That makes it fast and lightweight, which is why real-time video, voice, gaming, and DNS lookups often use UDP where a lost packet matters less than speed.

AspectTCPUDP
ConnectionConnection-oriented (handshake)Connectionless
ReliabilityGuaranteed, ordered deliveryNo delivery guarantee
OverheadHigherLower
Good forWeb, email, file transferVideo, voice, gaming, DNS

Key point: each protocol maps to a real use: TCP for web and files, UDP for streaming and DNS. Matching the protocol to the workload is the mature answer.

Watch a deeper explanation

Video: Computer Networking Full Course: OSI Model Deep Dive with Real Life Examples (Kunal Kushwaha, YouTube)

Q6. What is an IP address, and how do IPv4 and IPv6 differ?

An IP address is a numeric label that identifies a device on a network so packets can be routed to it. IPv4 addresses are 32 bits, written as four decimal octets like 192.168.1.10, giving about 4.3 billion addresses.

IPv6 uses 128-bit addresses written in hexadecimal, giving a practically unlimited pool, which is why it exists: IPv4 ran out. IPv6 also simplifies the header and builds in features that were add-ons in IPv4. Both still coexist today.

Key point: The 'why IPv6' answer is address exhaustion. Naming that, plus 32 vs 128 bits, is enough to pass this one cleanly.

Q7. What is the difference between a public and a private IP address?

A public IP is globally routable on the internet and must be unique. A private IP comes from reserved ranges (like 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) used inside local networks and is not routable on the public internet.

Many devices on a home or office LAN share one public IP using NAT: the router translates private addresses to the single public one on the way out. That's why your laptop's 192.168.x.x address is private while the internet sees your router's public address.

Key point: private IPs connects to NAT. Explaining how many private addresses share one public IP shows you understand why the split exists.

Q8. What is a subnet mask and what does it do?

A subnet mask splits an IP address into a network portion and a host portion. The bits set to 1 mark the network part; the bits set to 0 mark the host part. For 255.255.255.0, the first three octets are the network and the last is the host.

Its job is to let a device decide whether a destination is on the same local network (deliver directly) or on a different one (send to the router). CIDR notation like /24 is just a shorthand for how many leading bits are the network part.

Key point: Explain the practical use: the mask decides local-vs-remote delivery. That's more useful than reciting bit counts alone.

Q9. What is DNS and why is it needed?

DNS (Domain Name System) is the internet's directory: it translates human-readable names like example.com into the IP addresses machines use to connect. Without it, you'd have to remember numeric addresses for every site, and any server changing its IP would break every link pointing at it.

It's a distributed hierarchy of servers, so no single machine holds every name. When you look up a name, the resolution walks from a root server to the top-level domain server to the domain's authoritative server, and results get cached along the way to keep it fast.

Key point: Call DNS 'the internet's phone book' and mention caching. Both come up as follow-ups and show you know it's distributed, not one server.

Q10. What is DHCP and what does it do?

DHCP (Dynamic Host Configuration Protocol) automatically assigns IP configuration to devices when they join a network: an IP address, subnet mask, default gateway, and DNS servers. Without it, every device would need manual configuration, which doesn't scale past a handful of machines and invites duplicate-address mistakes.

When a device connects, it broadcasts a request, a DHCP server offers an address from its pool, the device accepts, and the server leases it for a set time. The classic sequence is discover, offer, request, acknowledge, often called DORA.

Key point: Naming the DORA steps (discover, offer, request, acknowledge) is a quick way to show you know the actual exchange, not just the acronym.

Q11. What is the difference between HTTP and HTTPS?

HTTP is the protocol browsers and servers use to exchange web pages, and it sends data in plaintext. HTTPS is HTTP running over TLS, so the connection is encrypted, the data can't be read or tampered with in transit, and the server's identity is verified with a certificate.

HTTP uses port 80, HTTPS uses port 443. The MDN overview of HTTP is the standard reference here. In practice everything uses HTTPS now, because plaintext HTTP leaks credentials and content to anyone on the path.

Key point: Say HTTPS is 'HTTP over TLS', not a separate protocol. That precise phrasing is what the interviewer is listening for.

Q12. What is the difference between a hub, a switch, and a router?

A hub is a dumb repeater at the physical layer: it copies every incoming frame out of every other port, which wastes bandwidth and causes collisions. A switch works at the data link layer: it learns MAC addresses and forwards a frame only to the port where its destination lives.

A router works at the network layer: it connects different networks and forwards packets between them based on IP addresses, choosing a path toward the destination. In short: hub floods, switch forwards within a network by MAC, router routes between networks by IP.

DeviceOSI layerForwards by
HubPhysical (1)Nothing; repeats to all ports
SwitchData link (2)MAC address, to one port
RouterNetwork (3)IP address, between networks

Key point: The clean summary is 'hub floods, switch forwards by MAC, router routes by IP'. Mapping each to its layer seals the answer.

Watch a deeper explanation

Video: Hub, Switch, and Router Explained: What's the difference? (PowerCert Animated Videos, YouTube)

Q13. What is the difference between a MAC address and an IP address?

A MAC address is a hardware identifier burned into a network interface, unique to that device, and used for delivery on the local network segment at the data link layer. An IP address is a logical address at the network layer, used to route packets across networks and it can change depending on the network you join.

The analogy: the IP address is like the street address that gets a letter to the right building across the world, while the MAC address is like the specific mailbox that gets it to the right device on the final local hop. ARP is what links the two.

Key point: The 'IP routes across networks, MAC delivers on the local link' distinction, plus naming ARP as the link, is exactly what this checks.

Q14. What is a network protocol?

A protocol is an agreed set of rules for how devices format, transmit, and interpret data so they can communicate. Both sides follow the same rules, which is what lets machines from different vendors talk to each other.

Protocols define things like message format, the order of exchanges, error handling, and addressing. Examples by layer: Ethernet at the link layer, IP at the network layer, TCP and UDP at the transport layer, and HTTP, DNS, and SMTP at the application layer.

Key point: Give one example per layer, not just a definition. Naming a protocol at each layer proves you see protocols as a stack, which is what the question needs.

Q15. What is the difference between a packet, a frame, and a segment?

They're the same data described at different layers, each wrapping the one above it. A segment is the transport-layer unit (TCP segment or UDP datagram). Wrap it with an IP header and it's a packet at the network layer. Wrap that with a link-layer header and trailer and it's a frame on the wire.

This wrapping is called encapsulation: as data goes down the stack, each layer adds its own header; as it goes up on the receiving side, each layer strips its header off. Using the right term for the right layer signals you actually understand the model.

Key point: Getting the terms right per layer (segment, packet, frame) and naming encapsulation is a small detail that indicates real understanding.

Q16. What is the difference between bandwidth and latency?

Bandwidth is how much data a link can carry per unit of time, measured in bits per second. Latency is how long a single bit takes to travel from source to destination, measured in milliseconds. They're independent: a link can be high-bandwidth but high-latency.

The common analogy is a highway: bandwidth is how many lanes it has (how much can flow at once), while latency is how long the drive takes end to end. A satellite link can move lots of data (high bandwidth) yet feel slow because each bit travels a long way (high latency).

Key point: Keep bandwidth and latency separate: 'lanes vs travel time'. Conflating them is the classic slip this question is designed to catch.

Q17. What are the common network topologies?

Topology is the shape of how devices are connected. Star connects every device to a central switch or hub, which is the standard for modern LANs because one failed link only drops one device. Bus runs everything on one shared cable, mesh links devices directly to many others, and ring passes traffic around a loop.

Each trades cost against resilience. Star is cheap and easy to troubleshoot but depends on the central device. Mesh is expensive to wire but survives many link failures, which is why the internet's backbone is roughly a partial mesh. Bus and ring are mostly historical now.

TopologyStrengthWeakness
StarEasy to manage, one failure is isolatedCentral device is a single point of failure
MeshVery resilient, many redundant pathsExpensive, lots of links to wire
Bus / RingSimple, low cablingOne break can disrupt the whole segment

Key point: Anchor on why star won for LANs: cheap, and one bad link drops only one device. That reasoning matters more than listing every shape.

Q18. What is the difference between unicast, broadcast, and multicast?

These describe how many recipients a message targets. Unicast is one sender to one receiver, the normal case for most traffic like loading a web page. Broadcast is one sender to every device on the local network, which is how ARP and some discovery protocols work.

Multicast is one sender to a specific group of interested receivers, which is far more efficient than broadcasting to everyone when only some devices care. Streaming a video feed to many subscribers at once is a classic multicast use. Broadcast doesn't cross routers; it stays inside the local segment.

Key point: Note that broadcast stays local and doesn't cross routers. That boundary detail is a frequent follow-up and ties back to broadcast domains.

Q19. Which protocols live at which OSI layer?

Mapping protocols to layers is a standard drill, so it helps to have a few anchors ready. the question needs to see you a protocol name connects to the job its layer does, not just recite a list. Getting a couple wrong signals shaky fundamentals.

The reliable anchors: Ethernet and ARP at the data link layer, IP and ICMP at the network layer, TCP and UDP at the transport layer, and HTTP, DNS, SMTP, and FTP up at the application layer. When unsure, reason from the job: if it addresses hosts across networks it's layer 3, if it delivers end to end it's layer 4.

LayerExample protocols
Application (7)HTTP, DNS, SMTP, FTP
Transport (4)TCP, UDP
Network (3)IP, ICMP
Data link (2)Ethernet, ARP

Key point: When you blank on a protocol's layer, reason from its job out loud. Showing that method beats memorization and is what the interviewer actually rewards.

Back to question list

Computer Networks Intermediate Interview Questions

Intermediate17 questions

For candidates with coursework or hands-on time: the TCP handshake, subnetting, routing, NAT, and the judgment questions that separate people who memorized protocols from people who understand them.

Q20. Explain the TCP three-way handshake.

It's how TCP opens a reliable connection. The client sends a SYN with its initial sequence number. The server replies with a SYN-ACK: its own SYN plus an acknowledgment of the client's. The client sends a final ACK, and the connection is established so data can flow.

The point of the exchange is that both sides agree on starting sequence numbers and confirm each other can send and receive. Closing the connection uses a similar FIN/ACK exchange, usually described as a four-way handshake.

The TCP three-way handshake

1SYN
client sends SYN with its initial sequence number
2SYN-ACK
server replies with its own SYN and acknowledges the client's
3ACK
client acknowledges the server's SYN; connection is open
4Data
both sides can now send data reliably

Connection teardown mirrors this with a FIN/ACK exchange, commonly called a four-way handshake.

Key point: Say why it's three steps: both sides must confirm send and receive and agree on sequence numbers. Reciting SYN, SYN-ACK, ACK without the 'why' is weaker.

Q21. How does subnetting work, and why do we subnet?

Subnetting divides a larger network into smaller ones by borrowing bits from the host portion of an address to create more network segments. The subnet mask (or CIDR prefix like /26) decides how many bits are network and how many are host, which sets how many subnets and how many hosts per subnet you get.

We subnet to reduce broadcast traffic, improve security by isolating segments, and use address space efficiently instead of wasting a huge flat range. For example, a /24 has 256 addresses; splitting it into four /26 subnets gives four segments of 64 addresses each.

  • Borrowing host bits creates more subnets with fewer hosts each.
  • A /24 gives 254 usable hosts; a /26 gives 62; a /30 gives 2 (good for point-to-point links).
  • Network and broadcast addresses in each subnet aren't usable by hosts.

Key point: Be ready to compute usable hosts for a given prefix. Knowing a /30 gives two usable hosts (point-to-point links) is a common quick check.

Q22. Walk through what happens during a DNS lookup.

First the resolver checks caches: the browser, the OS, then the configured DNS resolver. On a miss, the recursive resolver walks the hierarchy: it asks a root server, which points to the top-level domain server (like .com), which points to the domain's authoritative name server, which returns the actual IP.

The resolver caches the answer with a TTL so repeat lookups are instant until it expires. This hierarchy and caching is what makes DNS scale to the whole internet without any single server knowing every name.

  • Caches checked first: browser, OS, then recursive resolver.
  • On a miss: root server, then TLD server, then authoritative server.
  • Answer cached with a TTL to speed up repeat lookups.

Key point: Mention TTL and caching, not just the root/TLD/authoritative chain. The caching layer is what interviewers probe when they ask why DNS is fast.

Q23. What happens when you type a URL into a browser and press enter?

The browser resolves the domain to an IP via DNS, then opens a TCP connection to the server (a three-way handshake), and for HTTPS performs a TLS handshake to set up encryption. Then it sends an HTTP request, usually a GET for the page.

The server responds with HTML, and the browser parses it, discovers linked assets (CSS, JavaScript, images), fetches those over more requests, builds the DOM and render tree, and paints the page. Under the hood, IP routing moves every one of those packets across networks to the server and back.

What happens when you type a URL and press enter

1DNS
resolve the domain name to an IP address
2TCP + TLS
open a TCP connection, then a TLS handshake for HTTPS
3HTTP request
browser sends a GET; server responds with HTML
4Render
browser parses HTML, fetches assets, paints the page

This one walkthrough touches DNS, TCP, TLS, HTTP, and rendering, which is why interviewers love it.

Key point: This is the classic full-stack networking question. Hit every layer in order, DNS, TCP, TLS, HTTP, render, and you demonstrate the whole stack in one answer.

Q24. What is NAT and why is it used?

NAT (Network Address Translation) rewrites IP addresses as packets pass through a router. The most common form maps many private addresses on a LAN to one public address, tracking connections so replies get back to the right internal device.

It exists mainly to conserve scarce IPv4 addresses: a whole home or office shares one public IP. A side effect is a basic layer of privacy and isolation, since internal addresses aren't directly reachable from outside, though NAT isn't a real firewall.

Key point: Frame NAT's main purpose as IPv4 conservation, and note it's not a firewall. Overselling NAT as security is a common mistake here.

Q25. What is the difference between flow control and congestion control in TCP?

Flow control protects the receiver: it stops a fast sender from overwhelming a slow receiver's buffer, managed with the receiver's advertised window. Congestion control protects the network: it stops senders from overwhelming the links and routers between them.

They solve different problems with different signals. Flow control uses the receive window the receiver advertises. Congestion control uses algorithms like slow start and congestion avoidance that react to signs of loss or delay in the network, adjusting how much the sender puts in flight.

Flow controlCongestion control
ProtectsThe receiver's bufferThe network's capacity
SignalReceiver's advertised windowPacket loss / delay
MechanismSliding windowSlow start, congestion avoidance

Key point: The one-line distinction is 'flow control protects the receiver, congestion control protects the network'. Mixing them up is the trap.

Q26. How does a router decide where to send a packet?

The router looks at the packet's destination IP and consults its routing table, which lists networks and the next hop to reach each. It picks the most specific matching route (longest prefix match) and forwards the packet to that next hop, decrementing the TTL as it goes.

Routing tables are built either statically (an admin configures routes) or dynamically with routing protocols. If no route matches, the packet goes to the default route (the gateway of last resort), and if even that's missing, it's dropped.

Key point: Naming 'longest prefix match' and the default route shows you know how forwarding actually decides, not just that a table exists.

Q27. What is the difference between OSPF and BGP?

OSPF (Open Shortest Path First) is an interior gateway protocol: it routes within a single organization's network (an autonomous system), building a map of the topology and computing shortest paths. It converges fast and reacts to link changes inside your network.

BGP (Border Gateway Protocol) is the exterior protocol that routes between autonomous systems, and it's what stitches the whole internet together. BGP chooses paths based on policy and the sequence of networks a route passes through, not just shortest distance, because it deals with business relationships between providers.

OSPFBGP
ScopeWithin one network (interior)Between networks (exterior)
Decides byShortest path / link costPolicy and AS path
Used forInternal routingRouting the internet

Key point: The split is 'OSPF inside an organization, BGP between organizations'. Adding that BGP is policy-driven is the intermediate-level nuance.

Q28. What are ports and sockets?

A port is a number that identifies a specific service or process on a device, so one machine with one IP can run many services at once (web on 443, SSH on 22, DNS on 53). The transport layer uses ports to deliver data to the right application.

A socket is the combination of an IP address and a port, plus the protocol, that identifies one endpoint of a connection. A TCP connection is uniquely identified by the four-tuple of source IP, source port, destination IP, and destination port.

Key point: Knowing a connection is identified by the four-tuple (source and destination IP and port) is the detail that separates a solid answer from a vague one.

Q29. Which well-known ports and their protocols should you know?

A handful of well-known ports come up constantly, so it's worth having them memorized cold. They span the application-layer services you interact with every day, from web traffic to remote login to name resolution to sending mail, and each one identifies a specific service on a host.

Interviewers sometimes rapid-fire these to check your fluency, so know at least HTTP, HTTPS, SSH, DNS, and SMTP without hesitation.

PortProtocolUse
22SSHSecure remote login
53DNSName resolution
80HTTPWeb (plaintext)
443HTTPSWeb (encrypted)
25 / 587SMTPSending email

Key point: Have HTTP (80), HTTPS (443), SSH (22), and DNS (53) instant. Fumbling the everyday ports indicates someone who hasn't touched real networking.

Q30. How do the TCP and UDP headers differ, and why?

The UDP header is tiny, just source port, destination port, length, and checksum, eight bytes total. That's all UDP needs because it doesn't track connections or guarantee delivery, so there's nothing to record between packets and no state to carry from one datagram to the next.

The TCP header is larger (20 bytes minimum) because it carries what reliability needs: sequence and acknowledgment numbers for ordering and retransmission, a window size for flow control, and control flags like SYN, ACK, and FIN for connection state. The header size difference is a direct reflection of what each protocol promises.

Key point: the header size maps to the guarantee: TCP's bigger header carries sequence numbers, window, and flags. That cause-and-effect framing is what makes the answer stronger.

Q31. What is ICMP, and how do ping and traceroute use it?

ICMP (Internet Control Message Protocol) carries control and error messages for IP, like 'destination unreachable' or 'time exceeded'. It's not for carrying application data; it's how the network reports problems back to senders and answers the diagnostic probes that tools like ping and traceroute rely on.

Ping sends ICMP echo requests and times the echo replies to measure reachability and round-trip time. Traceroute sends packets with increasing TTL values: each router that decrements TTL to zero returns an ICMP time-exceeded message, which reveals each hop along the path.

bash
# is the host reachable, and how fast?
ping example.com

# what path do packets take to get there?
traceroute example.com

Key point: Explaining the TTL trick behind traceroute (each hop replies when TTL hits zero) shows you understand the mechanism, not just the command name.

Q32. How does ARP work?

ARP (Address Resolution Protocol) finds the MAC address for a known IP on the local network. When a device wants to send to a local IP but doesn't know its MAC, it broadcasts an ARP request asking who has that IP; the owner replies with its MAC address.

The result is cached in an ARP table for a while so the device doesn't ask again for every packet. ARP only works within a single local network segment; to reach a device on another network, the sender uses ARP to find the router's MAC, and the router takes it from there.

Key point: The key insight is ARP resolves IP to MAC only on the local segment, and for remote hosts you ARP for the router. That routing nuance is what's being tested.

Q33. What is the difference between a collision domain and a broadcast domain?

A collision domain is the set of devices whose frames can collide on a shared medium. Hubs put everything in one collision domain; switches break it up because each switch port is its own collision domain, which is why switches replaced hubs.

A broadcast domain is the set of devices that receive each other's broadcast frames. A switch forwards broadcasts to all its ports, so a plain switched network is one broadcast domain. Routers and VLANs are what separate broadcast domains, which is one reason we subnet and use VLANs.

Key point: Say switches break up collision domains but not broadcast domains, and routers/VLANs break up broadcast domains. That precise pairing is the whole point of the question.

Q34. What happens during a TLS handshake?

TLS sets up an encrypted, authenticated connection before any HTTP data flows. The client and server agree on a protocol version and cipher, the server presents its certificate so the client can verify its identity against a trusted authority, and they exchange keying material to derive a shared session key.

Once the handshake finishes, both sides use fast symmetric encryption with that session key for the actual data. Modern TLS uses key exchange methods that give forward secrecy, so capturing traffic today and stealing the server's key later still can't decrypt past sessions.

Key point: Mention certificate verification for identity and forward secrecy for the key exchange. Those two points show you understand what TLS actually protects against.

Q35. How do HTTP cookies keep a stateless protocol stateful?

HTTP itself is stateless: each request stands alone and the server remembers nothing between them. Cookies bridge that gap. The server sends a Set-Cookie header, the browser stores it, and it attaches the cookie on every later request to the same site, so the server can recognize a returning user.

A typical login stores a session ID in a cookie; the server keeps the real session data server-side, keyed by that ID. Flags matter for safety: HttpOnly hides the cookie from JavaScript, Secure sends it only over HTTPS, and SameSite limits cross-site sending to blunt CSRF.

Key point: Say HTTP is stateless and cookies add the state on top, then name HttpOnly, Secure, and SameSite. The security flags are where intermediate answers separate from junior ones.

Q36. What is the difference between HTTP GET and POST?

GET requests a resource and puts its parameters in the URL query string, so it should only read data, never change it. Because GET is safe and idempotent, browsers and caches can repeat it freely and it shows up in history and logs.

POST sends data in the request body to create or change something on the server, so it's not idempotent: submitting twice can create two records, which is why browsers warn before resending a POST. The rule of thumb is GET to read, POST (or PUT/PATCH/DELETE) to write.

GETPOST
Data locationURL query stringRequest body
PurposeRead a resourceCreate or change a resource
IdempotentYesNo
CacheableYesNot by default

Key point: Frame it as 'GET reads, POST writes' and mention idempotency. Saying POST just hides data in the body while GET shows it misses the real semantic difference.

Back to question list

Computer Networks Interview Questions for Experienced Engineers

Experienced14 questions

advanced rounds probe protocol internals, performance, security, and production scars. Expect every answer here to draw a follow-up about trade-offs and failure modes.

Q37. How does TCP congestion control actually work?

TCP keeps a congestion window that limits how much unacknowledged data is in flight. It starts small and uses slow start, doubling the window each round trip until it hits a threshold or sees loss. After that it shifts to congestion avoidance, growing the window slowly and linearly to probe for more capacity gently.

When loss signals congestion, classic TCP cuts the window (fast retransmit and fast recovery for a single loss, a larger cut for a timeout). Newer algorithms like CUBIC scale better on high-bandwidth links, and BBR models bandwidth and round-trip time directly instead of treating loss as the only congestion signal.

Key point: Naming slow start, congestion avoidance, and a modern algorithm like CUBIC or BBR signals you understand congestion control as an evolving system, not one fixed rule.

Q38. What are the differences between HTTP/1.1, HTTP/2, and HTTP/3?

HTTP/1.1 sends one request at a time per connection and suffers head-of-line blocking, so browsers open many connections to work around it. HTTP/2 multiplexes many streams over one TCP connection and adds header compression, but a single lost TCP packet still stalls all streams because TCP delivers in order.

HTTP/3 moves off TCP onto QUIC, which runs over UDP and handles streams independently, so one lost packet only blocks its own stream, not the others. QUIC also folds the TLS handshake into the connection setup, cutting round trips. The through-line is each version attacking head-of-line blocking at a lower layer.

VersionTransportKey change
HTTP/1.1TCPOne request at a time per connection
HTTP/2TCPMultiplexed streams, header compression
HTTP/3QUIC over UDPIndependent streams, faster setup

Key point: The unifying theme is head-of-line blocking pushed lower each version, ending at QUIC. Framing it as one problem attacked repeatedly beats listing features.

Q39. How does load balancing work, and what's the difference between L4 and L7?

A load balancer spreads incoming traffic across a pool of backend servers and removes unhealthy ones via health checks, so no single server is overwhelmed and one failure doesn't take the service down. It's the front door that makes horizontal scaling and zero-downtime deploys possible.

Layer 4 load balancing routes by IP and port without inspecting the payload, so it's fast and protocol-agnostic. Layer 7 load balancing understands the application protocol (HTTP), so it can route by URL path, host, or headers, terminate TLS, and do content-based decisions, at the cost of more processing per request.

Key point: The L4-vs-L7 trade is speed versus smarts: L4 routes by IP/port, L7 routes by HTTP content. Knowing when each fits is the production signal.

Q40. How does a CDN work, and what problems does it solve?

A CDN (Content Delivery Network) is a fleet of servers spread across many locations that cache and serve content close to users. When someone requests an asset, they're routed to a nearby edge server instead of the distant origin, which cuts latency and offloads traffic from the origin.

It solves latency (physics: closer is faster), scale (the edge absorbs traffic spikes so the origin doesn't melt), and availability (content stays served even if the origin is busy). CDNs handle static assets well and increasingly cache dynamic content and run logic at the edge. The hard parts are cache invalidation and keeping cached content fresh.

Key point: Lead with 'serve content close to the user to cut latency', then name cache invalidation as the hard part. That balance of benefit and cost indicates experienced.

Q41. How do firewalls work, and what are stateful vs stateless firewalls?

A firewall controls traffic by matching packets against rules and allowing or dropping them, based on things like source and destination IP, port, and protocol. It's the boundary control between networks of different trust levels.

A stateless firewall evaluates each packet in isolation against its rules, with no memory of prior packets. A stateful firewall tracks active connections, so it can allow return traffic for a connection it already permitted without a separate rule, which is both more convenient and more secure. Modern next-generation firewalls add application-aware inspection on top.

StatelessStateful
Tracks connectionsNoYes
Return trafficNeeds explicit rulesAllowed automatically
OverheadLowerHigher (keeps state)

Key point: The stateful firewall's edge is tracking connections so return traffic is handled automatically. Explaining why that's safer, not just different, is The production-ready answer.

Q42. How does a VPN work?

A VPN (Virtual Private Network) creates an encrypted tunnel between a client and a VPN server over the public internet. Traffic inside the tunnel is encrypted and encapsulated, so anyone on the path sees only the outer packets to the VPN server, not the actual destinations or contents.

It's used to reach a private network remotely as if you were local (site-to-site or remote-access) and to shield traffic on untrusted networks. The trade-offs are the extra latency of routing through the VPN server and the trust you place in whoever runs it, since they can see your decrypted traffic at the exit.

Key point: Note the trust and latency cost of routing through the VPN provider. Acknowledging that the exit point sees decrypted traffic shows you understand the real threat model.

Q43. What are the main DNS record types and what do they do?

The everyday set: A maps a name to an IPv4 address, AAAA to an IPv6 address, and CNAME aliases one name to another. MX names the mail servers for a domain, TXT holds arbitrary text often used for verification and email security (SPF, DKIM), and NS delegates a zone to its authoritative name servers.

Knowing these matters for real work: a misconfigured MX breaks email, a wrong CNAME or missing AAAA breaks reachability, and TXT records are where SPF, DKIM, and domain verification live. Each record also carries a TTL controlling how long resolvers cache it.

RecordMaps / holds
A / AAAAName to IPv4 / IPv6 address
CNAMEName to another name (alias)
MXMail servers for the domain
TXTText: SPF, DKIM, verification
NSAuthoritative name servers for the zone

Key point: Being able to say which record breaks which service (MX for mail, A/AAAA for reachability) proves you've actually operated DNS, not just defined it.

Q44. What are common network attacks and how do you defend against them?

The recurring ones: a DDoS floods a target with traffic to exhaust its capacity, a man-in-the-middle intercepts traffic between two parties, DNS spoofing feeds a resolver false answers, and ARP spoofing poisons a local network's IP-to-MAC mapping to redirect traffic.

Defenses layer up: TLS everywhere defeats passive interception and detects tampering, DNSSEC signs DNS answers to block spoofing, rate limiting and upstream scrubbing absorb DDoS, and network segmentation plus monitoring limit the blast radius of a local attack. The principle is defense in depth, because any single control can be bypassed.

Key point: Pair each attack with its defense (TLS for MITM, DNSSEC for spoofing) rather than listing threats. Matching problem to mitigation is what a security-minded interviewer wants.

Q45. What is QUIC and why was it created?

QUIC is a transport protocol built on UDP that underpins HTTP/3. It provides reliable, multiplexed, encrypted streams, essentially reimplementing TCP's reliability plus TLS's security in user space on top of UDP, which lets it evolve without waiting on operating-system kernel changes.

It was created to fix TCP's limits for the modern web: TCP's in-order delivery causes head-of-line blocking across independent streams, and its handshake plus a separate TLS handshake costs round trips. QUIC handles streams independently so one lost packet doesn't stall the rest, and it folds encryption into connection setup, cutting startup latency, with connection migration that survives a network change like Wi-Fi to cellular.

Key point: The strong points are user-space evolvability, independent streams, and connection migration. Naming why TCP couldn't just be patched shows deep transport-layer understanding.

Q46. How do you reduce latency in a networked application?

Start by cutting distance and round trips, because those dominate. Put content close to users with a CDN or edge nodes, reuse connections instead of opening new ones per request, and reduce the number of round trips (connection reuse, HTTP/2 or HTTP/3, TLS session resumption). Distance is bounded by the speed of light, so serving from nearby is the biggest lever.

Then trim the rest: compress responses, cache aggressively with sensible invalidation, batch small requests, and move work closer to the user or precompute it. Measure with real percentiles (p95, p99), not averages, because tail latency is what users actually feel, and one slow dependency or an extra handshake round trip is often the culprit.

Where a request spends time: relative latency by source

Orders of magnitude, not exact figures. A cross-continent round trip dominates, which is why moving content closer (a CDN) and cutting round trips matters most.

Same-datacenter round trip
1 relative latency
Same-region round trip
10 relative latency
Cross-continent round trip
100 relative latency
TLS handshake (extra round trips)
200 relative latency
  • Same-datacenter round trip: Under a millisecond within one facility
  • Same-region round trip: A few milliseconds across a metro or region
  • Cross-continent round trip: Tens of milliseconds, bounded by distance and speed of light
  • TLS handshake (extra round trips): Each extra round trip multiplies the base latency

Key point: Anchor the answer in 'cut distance and round trips first, measure with p99'. Jumping to micro-optimizations before addressing round trips is the junior instinct.

Q47. How does socket programming work at a high level?

A socket is the programming interface to the transport layer. A TCP server creates a socket, binds it to an address and port, listens, and accepts incoming connections, each accept returning a new socket for that client. The client creates a socket and connects to the server's address and port, then both read and write bytes over their sockets.

The key mental model is that a TCP connection is a byte stream, not messages, so the application must frame its own messages (length prefixes or delimiters) because reads can return partial or coalesced data. UDP sockets skip the connection setup and send discrete datagrams instead, which is why UDP code looks simpler but shifts reliability onto the application.

python
# minimal TCP server
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("0.0.0.0", 8080))
s.listen()
conn, addr = s.accept()   # blocks until a client connects
data = conn.recv(1024)    # a byte stream, not a message

Key point: The insight that scores is 'TCP is a byte stream, so you must frame your own messages'. Candidates who assume one recv equals one message get caught here.

Q48. Design question: how would you architect a service to handle millions of concurrent connections?

Clarify first: what protocol, are connections long-lived (like websockets) or short, what's the read/write pattern, and what latency does the business need. Then lay out the shape: stateless application servers behind load balancers so you scale horizontally, with connection state pushed into shared stores so any server can handle any request. For huge connection counts, use event-driven, non-blocking I/O (epoll-style) so one server holds many connections without a thread each.

Then handle the parts that don't scale by adding boxes: use a CDN and edge termination to keep long-haul traffic down, shard or replicate the data tier, add caching for hot reads, and spread across availability zones and regions for resilience. The structure that scores is clarify, scale stateless horizontally, offload state and connections, protect the data tier, each choice justified by the requirements you asked for.

Key point: Open by asking clarifying questions and mention non-blocking I/O for the connection count. Jumping straight to 'add more servers' without addressing per-connection cost underperforms on this prompt.

Q49. How do WebSockets differ from HTTP, and when do you use them?

Plain HTTP is request-response: the client asks, the server answers, and the connection is done. That's a poor fit for real-time updates, because the client has to keep polling to ask 'anything new yet?'. WebSockets fix that with a single long-lived, full-duplex connection where either side can send a message any time.

The connection starts as an HTTP request with an Upgrade header, then switches protocols and stays open. Reach for WebSockets when you need low-latency two-way updates: chat, live dashboards, collaborative editing, multiplayer games. For occasional server-to-client updates only, Server-Sent Events are a simpler one-way alternative.

Key point: Explain the HTTP Upgrade that starts a WebSocket, and offer Server-Sent Events for one-way updates. Knowing the simpler alternative shows you pick the right tool, not the trendy one.

Q50. Walk me through how you'd diagnose a 'website won't load' problem.

Work up the stack so you isolate the layer instead of guessing. First confirm local connectivity: does the machine have a valid IP and can it reach its gateway. Then test DNS with nslookup or dig, because a name that won't resolve looks identical to a dead server from the browser.

If the name resolves, ping the IP and run traceroute to see whether packets reach the server and where they stop. Then test the application directly with curl to check the port, the TLS handshake, and the HTTP status code. Each step rules out one layer, so by the end you've located the fault rather than swapping parts at random.

bash
nslookup example.com        # does the name resolve?
ping 93.184.216.34          # is the server reachable?
traceroute example.com      # where does the path break?
curl -v https://example.com # port, TLS, and HTTP status

Troubleshooting 'the site won't load' from the bottom up

1Link and IP
is there a connection and a valid IP? check the interface and ping the gateway
2DNS
does the name resolve? nslookup or dig the domain
3Reachability
ping the server IP and traceroute to find where it stops
4Application
curl the URL; check port, TLS, and the HTTP status code

Working layer by layer isolates the fault fast instead of guessing, which is exactly the method the question needs to see.

Key point: Show the bottom-up method (link, DNS, reachability, application), not a random tool list. The systematic isolation is the whole point of this question.

Back to question list

OSI Model vs the TCP/IP Model

Both models describe networking as layers, but they serve different purposes. OSI is a seven-layer reference model built for teaching and for reasoning cleanly about where a problem lives. TCP/IP is the four-layer model the actual internet was built on, so it maps directly to real protocols. Knowing where they line up, and where OSI splits a job that TCP/IP keeps together, is a standard opening question. The key point to say out loud: OSI is the map you reason with, TCP/IP is the terrain that ships packets.

AspectOSI modelTCP/IP model
Number of layers7 (physical up to application)4 (link, internet, transport, application)
PurposeReference model for teaching and diagnosisThe stack the real internet runs on
Application handlingSplit into application, presentation, sessionOne combined application layer
Link and physicalTwo separate layersCombined into one link layer
Where it's usedExplaining and locating problemsActual protocol design and implementation

How to Prepare for a Computer Networks Interview

Prepare in layers, literally, and practice tracing a request end to end out loud. Most networking rounds move from definition questions to a trace-the-packet walkthrough to a scenario or troubleshooting discussion, so rehearse each stage rather than only memorizing definitions.

  • Learn the OSI and TCP/IP layers cold, then anchor every protocol you study to the layer it lives on.
  • Practice the 'what happens when you type a URL' walkthrough until it's automatic; it touches DNS, TCP, TLS, HTTP, and routing in one story.
  • Get hands-on: run ping, traceroute, nslookup, and read a short packet capture so your answers come from having seen the traffic.
  • Take the quiz on this page to find weak spots, then revisit those questions before the real round.

The typical networking interview flow

1Recruiter or phone screen
background, a few concept checks, layers and protocols you know
2Core concepts
OSI/TCP-IP, TCP vs UDP, IP addressing, DNS, HTTP
3Trace and troubleshoot
walk a request end to end, debug a broken connection
4Scenario and design
subnetting, scaling, security, latency follow-ups

Earlier rounds increasingly run as AI-driven technical interviews. The concepts on this page are what gets probed at every stage.

Test Yourself: Computer Networks Quiz

Ready to test your Computer Networks knowledge?

10 questions, about 6 minutes. Score 70% or higher to earn a shareable certificate.

10 questions Instant feedback Free certificate on 70%+

Frequently  Asked  Questions

Which Computer Networks topics should I prioritize before a technical round?

Prioritize the areas that change real decisions: fundamentals, practical tasks, debugging, trade-offs, and evidence. The highest-value questions are tied to a project example, a validation check, or a failure mode.

Do I need to memorize all seven OSI layers?

Yes, and more than the names: know what job each layer does and which protocols live there. Interviewers use the layers as a scaffold, then ask where a given protocol sits or where a problem would show up. Mnemonics help you recall the order, but understanding each layer's role is what actually gets evaluated.

Which topics come up most often?

The reliable core is the OSI and TCP/IP models, TCP vs UDP, IP addressing and subnetting, DNS resolution, HTTP and HTTPS, and the 'what happens when you type a URL' trace. Routing, switching, NAT, and the TCP three-way handshake round it out. If your target role is security or systems, expect deeper questions on TLS, firewalls, and congestion control.

How long does it take to prepare for a networking interview?

If you've taken a networking course, one to two weeks of an hour a day covers this bank with practice runs. Starting colder, plan three to four weeks and get hands-on: run traceroute and nslookup, read a packet capture, and draw the layers from memory. Reading definitions without seeing real traffic is how networking prep quietly fails.

Do interviewers ask exactly these questions?

The concepts repeat far more reliably than the exact wording. Interviewers rephrase, chain follow-ups, and push toward whatever you claim confidence in. Prepare the underlying ideas, the layered model, transport protocols, addressing, DNS, HTTP, and the phrasing takes care of itself.

Is there a way to test my networking knowledge?

Yes. The quiz on this page scores you as you go and explains every answer, so you find your weak spots fast. Pass the threshold and you can download a shareable certificate with your name and score, free and with no sign-up. It's the quickest way to check yourself before the real round.

From the team that builds coding interviews

Hyring builds the AI Coding Interviewer that runs live technical rounds in 20+ languages for 5,000+ hiring teams. These Computer Networks questions and scoring notes reflect what actually gets asked and evaluated inside the interviews we host.

See how the AI Coding Interviewer works

Sources

Adithyan RKWritten by Adithyan RK
Surya N
Fact-checked by Surya N
Published on: 12 Jun 2026Last updated: 12 Jul 2026
Share: