Interview Prep
Interview Questions on Computer Networks — OSI Model, TCP/IP, DNS, and What Gets Asked
Computer networks is a core subject in every IT interview — from campus placements at TCS and Infosys to system design rounds at product companies. Here are the questions that actually get asked, with the depth interviewers expect.

Computer networks questions appear in every IT fresher interview and most experienced-level system design rounds.
Why Computer Networks Is Always on the Interview
Computer networks is one of the four core CS subjects tested in Indian IT interviews — alongside OS, DBMS, and OOPs. For freshers, it appears in campus placement rounds at TCS, Infosys, Wipro, Cognizant, and HCL. For experienced candidates, networking concepts show up in system design rounds when discussing load balancers, CDNs, DNS resolution, and API communication.
The questions follow a predictable pattern: OSI model layers, TCP vs UDP, how DNS works, subnetting basics, and HTTP methods. If you know these five topics well, you can handle 80% of computer networks questions in any interview.
This guide covers the actual computer networks questions asked in Indian interviews — from basic concepts for freshers to protocol-level questions for experienced candidates.
Computer networks is the one subject where freshers and experienced candidates get asked the same foundational questions. The OSI model and TCP/IP are non-negotiable.
OSI Model Questions
The OSI model is the single most asked topic in computer networks interviews. You need to know all 7 layers, what each does, and which protocols operate at each layer.
Q1: Explain the 7 layers of the OSI model.
Layer 7: Application → HTTP, FTP, SMTP, DNS Layer 6: Presentation → SSL/TLS, encryption, compression Layer 5: Session → Session management, authentication Layer 4: Transport → TCP, UDP (port numbers) Layer 3: Network → IP, ICMP, routing (IP addresses) Layer 2: Data Link → Ethernet, MAC addresses, switches Layer 1: Physical → Cables, hubs, electrical signals Memory trick: "All People Seem To Need Data Processing" (Application → Physical, top to bottom) Or bottom-up: "Please Do Not Throw Sausage Pizza Away" What interviewers want: - Name all 7 layers in order - Give 1-2 protocols per layer - Explain what each layer DOES (not just the name) - Know which devices operate at which layer: Hub = Layer 1, Switch = Layer 2, Router = Layer 3
Q2: What is the difference between OSI model and TCP/IP model?
OSI Model (7 layers) TCP/IP Model (4 layers) ───────────────────── ───────────────────── Application Application Presentation (merged into Application) Session (merged into Application) Transport Transport Network Internet Data Link Network Access Physical (merged into Network Access) Key differences: - OSI is theoretical/reference model - TCP/IP is the practical model used on the internet - OSI has 7 layers, TCP/IP has 4 - OSI was designed first, then protocols were fitted - TCP/IP protocols were designed first, model came after
TCP vs UDP Questions
TCP vs UDP is asked in every single computer networks interview. The follow-up is always: “Give me a real-world example of when you would use each.”
Q3: What is the difference between TCP and UDP?
Feature TCP UDP ───────────── ───────────────── ────────────────── Connection Connection-oriented Connectionless Reliability Guaranteed delivery No guarantee Ordering Maintains order No ordering Speed Slower (overhead) Faster (no overhead) Header size 20 bytes minimum 8 bytes Flow control Yes (sliding window) No Use cases HTTP, FTP, Email DNS, Video, Gaming TCP 3-way handshake: Client → SYN → Server Client ← SYN-ACK ← Server Client → ACK → Server (Connection established) Real-world analogy: TCP = registered post (confirmed delivery) UDP = dropping a letter in a mailbox (hope it arrives) When to use UDP over TCP: - Live video streaming (dropped frame is better than lag) - Online gaming (speed > reliability) - DNS queries (small, single request-response) - VoIP calls (real-time audio)
Q4: Explain the TCP 3-way handshake. Why is it needed?
What interviewers want: Not just the SYN/SYN-ACK/ACK sequence, but WHY three steps are needed. The answer: both sides need to confirm they can send AND receive. Two steps would only confirm one direction.
Follow-up question: “What is a 4-way handshake?” — This is how TCP connections are closed. FIN → ACK → FIN → ACK. Both sides independently close their end of the connection.
DNS and HTTP Questions
“What happens when you type a URL in the browser?” is the most famous computer networks interview question. It tests DNS resolution, TCP connection, HTTP request/response, and rendering — all in one question.
Q5: What happens when you type google.com in the browser?
Step 1: DNS Resolution Browser cache → OS cache → Router cache → ISP DNS → Root DNS → TLD DNS → Authoritative DNS Result: google.com → 142.250.195.46 Step 2: TCP Connection 3-way handshake with the server IP on port 443 Step 3: TLS Handshake (HTTPS) Client Hello → Server Hello → Certificate exchange → Key exchange → Encrypted connection established Step 4: HTTP Request GET / HTTP/2 Host: google.com (headers, cookies, etc.) Step 5: Server Processing Server receives request, processes it, generates HTML Step 6: HTTP Response HTTP/2 200 OK Content-Type: text/html (HTML content) Step 7: Browser Rendering Parse HTML → Build DOM → Parse CSS → Build CSSOM → Render tree → Layout → Paint → Composite This single question can take 5-15 minutes depending on how deep the interviewer wants to go.
Q6: What are HTTP methods? Explain GET vs POST.
GET → Retrieve data (idempotent, cacheable) POST → Create data (not idempotent) PUT → Update/replace entire resource PATCH → Update partial resource DELETE → Remove resource GET vs POST: ───────────────────────────────────────────── GET POST Data in URL (query) Data in body Cacheable Not cacheable Bookmarkable Not bookmarkable Length limited (~2KB) No size limit Idempotent Not idempotent Less secure (URL visible) More secure (body) Status codes to know: 200 OK, 201 Created, 204 No Content 301 Moved Permanently, 302 Found (redirect) 400 Bad Request, 401 Unauthorized, 403 Forbidden 404 Not Found, 429 Too Many Requests 500 Internal Server Error, 503 Service Unavailable
Q7: What is the difference between HTTP and HTTPS?
Answer: HTTPS = HTTP + TLS/SSL encryption. HTTP sends data in plain text — anyone on the network can read it. HTTPS encrypts the data using TLS, so even if intercepted, it cannot be read. HTTPS uses port 443 (HTTP uses port 80). Google ranks HTTPS sites higher in search results.
Follow-up: “How does TLS work?” — Asymmetric encryption for key exchange (RSA/ECDHE), then symmetric encryption (AES) for data transfer. The TLS handshake establishes a shared secret key.

Understanding how data moves across networks is fundamental to every IT role — from development to DevOps to security.
IP Addressing and Subnetting
Q8: What is the difference between IPv4 and IPv6?
IPv4 IPv6 32-bit address 128-bit address 4.3 billion addresses 340 undecillion addresses Dotted decimal Hexadecimal with colons 192.168.1.1 2001:0db8:85a3::8a2e:0370 NAT required NAT not needed Header: 20-60 bytes Header: fixed 40 bytes Broadcast supported No broadcast (multicast) Private IP ranges (IPv4): 10.0.0.0 – 10.255.255.255 (Class A) 172.16.0.0 – 172.31.255.255 (Class B) 192.168.0.0 – 192.168.255.255 (Class C) Special addresses: 127.0.0.1 → localhost (loopback) 0.0.0.0 → all interfaces 255.255.255.255 → broadcast
Q9: What is subnetting? Calculate the subnet for 192.168.1.0/26.
/26 means 26 bits for network, 6 bits for hosts Subnet mask: 255.255.255.192 Binary: 11111111.11111111.11111111.11000000 Number of hosts per subnet: 2^6 - 2 = 62 usable Number of subnets: 2^2 = 4 Subnet 1: 192.168.1.0 – 192.168.1.63 Subnet 2: 192.168.1.64 – 192.168.1.127 Subnet 3: 192.168.1.128 – 192.168.1.191 Subnet 4: 192.168.1.192 – 192.168.1.255 Why -2 for usable hosts? First address = network address (192.168.1.0) Last address = broadcast address (192.168.1.63)
Practical and Scenario Questions
Q10: What is ARP? How does it work?
ARP (Address Resolution Protocol) maps IP addresses to MAC addresses. When a device wants to communicate on a local network, it knows the destination IP but needs the MAC address. ARP broadcasts “Who has 192.168.1.5?” and the device with that IP responds with its MAC address. The result is cached in the ARP table.
Q11: What is the difference between a hub, switch, and router?
Hub (Layer 1 — Physical) - Broadcasts to ALL ports - No intelligence, no filtering - Creates collisions, wastes bandwidth Switch (Layer 2 — Data Link) - Sends to SPECIFIC port using MAC address table - Learns which device is on which port - Eliminates unnecessary traffic Router (Layer 3 — Network) - Connects DIFFERENT networks - Routes using IP addresses - Makes forwarding decisions based on routing table - Provides NAT, firewall, DHCP Real-world analogy: Hub = shouting in a room (everyone hears) Switch = passing a note to a specific person Router = postal service between cities
Q12: What is a firewall? Types of firewalls?
A firewall monitors and filters network traffic based on security rules. It sits between a trusted internal network and an untrusted external network (the internet).
Types: Packet filtering (checks headers), Stateful inspection (tracks connection state), Application-level gateway/proxy (inspects content), Next-gen firewall (deep packet inspection + IPS + application awareness).
Q13: What is DHCP and how does it work?
DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses to devices on a network. The process follows DORA: Discover → Offer → Request → Acknowledge. The client broadcasts a discover message, the DHCP server offers an IP, the client requests it, and the server acknowledges. This is why your laptop gets an IP automatically when you connect to WiFi.
Q14: What is NAT? Why is it used?
NAT (Network Address Translation) translates private IP addresses to a public IP address. Your home router uses NAT — all devices (phone, laptop, TV) share one public IP but have different private IPs internally. NAT was created because IPv4 addresses ran out. It also adds a layer of security since internal IPs are hidden from the internet.
How to Prepare
Computer Networks — Priority Topics by Interview Type
Campus Placements
- • OSI model (all 7 layers)
- • TCP vs UDP
- • IP addressing basics
- • HTTP methods
- • Hub vs Switch vs Router
Experienced (Dev)
- • DNS resolution flow
- • HTTPS/TLS handshake
- • REST API design
- • WebSockets vs HTTP
- • CDN and caching
Network/DevOps
- • Subnetting calculations
- • Firewall rules
- • Load balancing
- • VPN and tunneling
- • Network troubleshooting