I have sat on both sides of the interview table for a long time, and I can tell you something that surprises most candidates: interviewers rarely want a textbook definition. They want to hear whether you actually understand what happens when two computers talk. This guide gives you the twenty questions that come up again and again, each answered the way you would say it out loud, with a real-world picture, a “what the interviewer wants to hear” note, and a few small programs whose output I ran so the numbers are real.
How to use this guide
Read the questions in order the first time, because later answers lean on earlier ones. Subnets make more sense after IP addresses, and the “what happens when you type a URL” question ties together half the list. After that, use the headings to jump to whatever you are weakest on.
The one rule for answering. Give the one-sentence definition first, then a quick real-world picture, then one detail that proves you have actually used it. Three short layers beat a long speech. If the interviewer wants more, they will ask, and that is when the conversation gets good.
Questions 1 to 5 cover the foundations. Questions 6 to 11 cover the protocols that make the internet work. Questions 12 to 15 cover devices and routing, and 16 to 20 cover security and troubleshooting.
Part 1: The foundations
Q1 What is a computer network, and what are LAN, WAN and MAN?
A network is two or more devices connected so they can exchange data. Everything else is about scale. A LAN (local area network) covers a small area such as a home, an office floor or a school lab. A MAN (metropolitan area network) spans a city or a campus. A WAN (wide area network) links networks across cities or countries, and the internet is the largest WAN there is.
Q2 Explain the OSI model and the TCP/IP model.
The OSI model is a seven-layer teaching framework for how data travels. Each layer does one job and talks only to the layers directly above and below it. The TCP/IP model is the four-layer version the real internet is built on. Interviewers love asking for both because the layers give you a map for troubleshooting.
A handy memory trick for the OSI layers from the top is: All People Seem To Need Data Processing (Application, Presentation, Session, Transport, Network, Data Link, Physical). In practice, people use the layer numbers as shorthand. When an engineer says “layer 2 problem,” they mean something about switches and MAC addresses. “Layer 3” means IP and routing, and “layer 4” means TCP or UDP ports.
Q3 What is an IP address? What is the difference between IPv4 and IPv6, and between public and private?
An IP address is the logical address of a device on a network, used to route data to it. IPv4 addresses are 32 bits long, written as four numbers such as 192.168.1.10, giving about 4.29 billion possible addresses (232 is exactly 4,294,967,296). That turned out not to be enough for a world of phones and sensors. IPv6 addresses are 128 bits, which gives roughly 3.4 × 1038 addresses, an almost unimaginable number.
Private addresses are reserved for use inside networks and are not routed on the public internet. The three ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Public addresses are unique across the internet. Because many homes reuse the same private ranges, NAT (Question 13) lets them all share one public address.
Q4 What is a subnet mask and what is subnetting?
A subnet mask tells a device which part of an IP address identifies the network and which part identifies the host. The mask 255.255.255.0 means the first three numbers name the network and the last one names the device. Engineers also write it as CIDR notation: 192.168.10.0/24, where 24 is the count of network bits.
Subnetting means cutting one large network into smaller ones, usually for tidiness, security or to reduce broadcast traffic. The useful formula: a network with a prefix length of n has 2(32 − n) addresses, and two of those are reserved (the network address and the broadcast address), so the usable host count is 2(32 − n) − 2. A /24 gives 254 hosts. A /26 gives 62.
Here is a short Python program that does the arithmetic with the standard ipaddress module. It splits a /24 into four /26 subnets.
import ipaddress
net = ipaddress.ip_network("192.168.10.0/24")
print(net, "has", net.num_addresses, "addresses,", net.num_addresses - 2, "usable hosts")
print("mask:", net.netmask)
print()
print("Split into four /26 subnets:")
for s in net.subnets(new_prefix=26):
hosts = list(s.hosts())
print(f"{str(s):<18} hosts {hosts[0]} - {hosts[-1]} broadcast {s.broadcast_address}")
Output:
192.168.10.0/24 has 256 addresses, 254 usable hosts
mask: 255.255.255.0
Split into four /26 subnets:
192.168.10.0/26 hosts 192.168.10.1 - 192.168.10.62 broadcast 192.168.10.63
192.168.10.64/26 hosts 192.168.10.65 - 192.168.10.126 broadcast 192.168.10.127
192.168.10.128/26 hosts 192.168.10.129 - 192.168.10.190 broadcast 192.168.10.191
192.168.10.192/26 hosts 192.168.10.193 - 192.168.10.254 broadcast 192.168.10.255
Read each line as a mini network: the first usable host, the last usable host, and the broadcast address at the end. Interviewers who ask this question often give you a block like 192.168.10.0/24 and ask you to carve out four equal subnets. The answer is the table above, and the trick is that each /26 holds 64 addresses, so the blocks start at 0, 64, 128 and 192.
Q5 What is the difference between a MAC address and an IP address?
A MAC address is a 48-bit hardware identifier burned into a network card, written like 3C:52:82:AB:12:EF. It is used for delivery within one local network. An IP address is assigned by software or a DHCP server, can change, and is used to route data between networks.
One more detail worth saying: as a packet crosses several routers, the IP addresses at both ends stay the same, but the MAC addresses are rewritten at every hop. That single sentence tells an interviewer you understand how layers 2 and 3 cooperate.
Part 2: The protocols that run the internet
Q6 What is the difference between TCP and UDP?
TCP is connection-oriented. It sets up a connection first, numbers the data, retransmits what is lost and delivers it in order. UDP is connectionless. It just sends packets with no handshake, no retransmission and no ordering guarantee, so it is faster and lighter.
| Feature | TCP | UDP |
|---|---|---|
| Connection | Handshake first | None |
| Delivery | Guaranteed and ordered | Best effort |
| Speed | Slower, more overhead | Faster, less overhead |
| Used for | Web pages, email, file transfer, SSH | DNS lookups, voice and video calls, games, streaming |
Q7 Explain the TCP three-way handshake.
Before TCP sends any data, the two sides agree to talk. The client sends a SYN (“I want to connect, my starting sequence number is X”). The server answers with SYN-ACK (“Got it, here is mine, Y”). The client finishes with an ACK (“Got yours too”). Now both sides know the other is alive and reachable, and they have agreed on sequence numbers for tracking data.
A bonus line that impresses: a SYN flood attack sends huge numbers of SYNs and never completes the handshake, leaving the server holding half-open connections. Defences include SYN cookies and rate limits.
Q8 What is DNS and how does a lookup work?
DNS, the Domain Name System, is the internet’s phone book. People remember names like example.com, but computers need IP addresses, and DNS translates one into the other.
When your device needs an address, it asks a recursive resolver, usually run by your ISP or a public DNS service. If the resolver does not already have the answer cached, it asks a root server, which points it to the server for the top-level domain (.com, .org, .in). That server points to the domain’s authoritative server, which gives the real answer. The resolver returns it to you and remembers it for the record’s time to live (TTL).
Know the common record types: A (name to IPv4), AAAA (name to IPv6), CNAME (an alias to another name), MX (mail servers) and NS (which servers are authoritative). Plain DNS uses UDP port 53, and TCP port 53 is used for large responses.
Q9 What is DHCP and how does it work?
DHCP, the Dynamic Host Configuration Protocol, automatically gives a device an IP address, subnet mask, default gateway and DNS servers when it joins a network. The exchange is nicknamed DORA: the client broadcasts a Discover, the server sends an Offer, the client sends a Request for that offer, and the server sends an Acknowledge. The address is a lease, not a permanent grant, and the client renews it before it expires.
Q10 What is ARP and why is it needed?
On a local network, devices deliver frames by MAC address, but programs only know IP addresses. ARP, the Address Resolution Protocol, bridges the gap. When your PC wants to reach 192.168.1.1 and does not know its MAC, it broadcasts “Who has 192.168.1.1?” to everyone. The owner replies with its MAC address. Your PC stores the answer in its ARP cache for a while, so it does not need to ask again.
The classic security follow-up is ARP spoofing: an attacker sends false ARP replies so that traffic meant for the gateway flows through their machine. Managed switches can defend against it with features such as dynamic ARP inspection.
Q11 What happens when you type a URL into your browser and press Enter?
Here is the version I recommend you tell, in order:
- 1. The browser checks its caches and the operating system’s cache for a known address.
- 2. DNS lookup. If nothing is cached, it resolves the name to an IP address (Question 8).
- 3. TCP connection. The browser opens a connection to port 443 with the three-way handshake (Question 7).
- 4. TLS handshake. For HTTPS, both sides agree on encryption and the server proves its identity with a certificate.
- 5. HTTP request. The browser sends
GET /with headers. - 6. The server responds with a status code (200 for success) and the page.
- 7. The browser renders the page, requesting images, scripts and styles, often over the same connection.
Mention that on your local network, the first packet needs ARP to find the gateway’s MAC address, and that routers along the way forward the packet by IP. That shows you can connect every layer in one story.
Part 3: Devices and routing
Q12 What is the difference between a hub, a switch and a router?
| Device | Works at | How it forwards | Intelligence |
|---|---|---|---|
| Hub | Layer 1 | Repeats every signal out of every port | None, and now rare |
| Switch | Layer 2 | Learns MAC addresses and sends frames only to the right port | Medium |
| Router | Layer 3 | Looks at IP addresses and connects different networks | High |
Q13 What is NAT?
NAT, Network Address Translation, lets many devices with private addresses share one public IP address. The router rewrites the source address and port of outgoing packets and keeps a table. When replies come back, it looks up the table and forwards them to the right internal device. The common form, where ports tell the devices apart, is often called PAT or NAT overload.
Know the side effects. NAT helped the world survive IPv4 exhaustion, and it hides internal addresses from the outside. But it is not a firewall, and it breaks anything that needs inbound connections, which is why we use port forwarding to reach a server inside a home network.
Q14 What is a default gateway, and how does a router choose where to send a packet?
A default gateway is the router a device uses for any destination outside its own subnet. Your laptop does not know how to reach the whole internet, so it hands everything non-local to the gateway.
A router keeps a routing table, a list of destination networks and where to send traffic for each. When a packet arrives, the router finds every entry that matches the destination and picks the most specific one, meaning the longest prefix. That is the longest prefix match. The entry 0.0.0.0/0 is the default route and matches everything, but because it is the least specific, it only wins when nothing better matches.
Here is a tiny router in Python with four routes:
import ipaddress
routes = {
"0.0.0.0/0": "ISP (default route)",
"10.0.0.0/8": "Head office core",
"10.1.0.0/16": "Branch office",
"10.1.2.0/24": "Branch lab network",
}
def lookup(dest):
ip = ipaddress.ip_address(dest)
best = None
for prefix, hop in routes.items():
net = ipaddress.ip_network(prefix)
if ip in net and (best is None or net.prefixlen > best[0].prefixlen):
best = (net, hop)
return best
for dest in ["10.1.2.50", "10.1.9.9", "10.7.7.7", "8.8.8.8"]:
net, hop = lookup(dest)
print(f"{dest:<10} matches {str(net):<12} -> {hop}")
Output:
10.1.2.50 matches 10.1.2.0/24 -> Branch lab network
10.1.9.9 matches 10.1.0.0/16 -> Branch office
10.7.7.7 matches 10.0.0.0/8 -> Head office core
8.8.8.8 matches 0.0.0.0/0 -> ISP (default route)
Look at the first line. The address 10.1.2.50 matches the /8, the /16 and the /24, and the /24 wins because it is the most specific. The last line matches only the default route, which sends it to the ISP.
One more thing interviewers like: routes can be static (written by an administrator) or dynamic (learned from other routers using protocols such as OSPF inside an organisation and BGP between internet providers). Static is simple and predictable. Dynamic adapts when links fail.
Q15 What is a VLAN and why would you use one?
A VLAN, virtual LAN, splits one physical switch into several logical networks. Devices in different VLANs cannot talk directly even if they are plugged into the same switch, and they need a router (or a layer 3 switch) to communicate. Frames carry a VLAN tag following the 802.1Q standard when they travel between switches.
The reasons to use them are security (keep guest Wi-Fi away from the finance team), performance (smaller broadcast domains) and tidiness (group devices by function, not by cable location).
Part 4: Security and troubleshooting
Q16 What is a firewall?
A firewall filters network traffic by rules, allowing or blocking it based on things like source, destination, port and protocol. A stateless firewall checks each packet alone against the rules. A stateful firewall tracks connections, so it knows that an incoming packet is a reply to something you started, and it allows it automatically. Modern “next-generation” firewalls also look at applications and can detect certain threats.
The principle to quote is default deny: block everything, then allow only what you need. That way, a mistake leaves you too closed instead of too open.
Q17 What is the difference between HTTP and HTTPS?
HTTP sends web traffic in plain text on port 80, so anyone on the path can read or alter it. HTTPS is the same protocol carried inside TLS encryption, usually on port 443. TLS gives you three things: confidentiality (nobody can read it), integrity (nobody can change it unnoticed) and authentication (a certificate proves you reached the real site).
If asked how the handshake works, a safe outline is: the client says hello and lists its supported options, the server answers with its certificate, the client checks the certificate against trusted authorities, and both sides agree on session keys, which then encrypt the data. Modern TLS also uses temporary keys, so recorded traffic stays unreadable even if a server key leaks later.
Q18 What is a VPN, and how is it different from a proxy?
A VPN creates an encrypted tunnel between your device and a VPN server, and typically sends all your traffic through it. Companies use VPNs so remote staff can reach internal systems as if they were in the office. A proxy is a server that makes requests on your behalf, usually for particular applications, and it may not encrypt anything. A VPN protects the whole path to the VPN server. A proxy mainly changes where the request appears to come from or adds filtering and caching.
Be careful with claims. A VPN hides your traffic from the local network and your ISP, but the VPN provider can see it instead. It does not make you anonymous.
Q19 How do you troubleshoot “the internet is not working”? What do ping and traceroute do?
Ping sends a small ICMP echo request and waits for a reply. It tells you whether a host is reachable and how long the round trip takes. Traceroute (called tracert on Windows) lists the routers on the path by sending packets with increasing TTL values, so each router in turn reports back when the TTL runs out. It shows you where along the path things slow down or stop.
My own habit is a four-step ladder, working outward until something fails:
- Ping 127.0.0.1. If this fails, the network software on your own machine is broken.
- Ping the default gateway. If this fails, the problem is local: cable, Wi-Fi, switch or gateway.
- Ping a public IP such as 8.8.8.8. If this works but names fail, you are nearly at DNS. If it fails, the problem is beyond the gateway, maybe the ISP.
- Ping a domain name. If the IP works but the name does not, DNS is the culprit.
Also check the basics early: is the address a 169.254 one (DHCP failed), is the cable plugged in, and did anything change recently? In my experience, most “mysterious” outages are one of those three.
Q20 What is the difference between bandwidth, latency and throughput?
Bandwidth is the maximum amount of data a link can carry per second, like the number of lanes on a highway. Latency is how long a single piece of data takes to get there, like the time for one car to complete the trip. Throughput is the amount that actually gets through in practice, which is usually lower than bandwidth because of congestion, errors and protocol overhead.
It is worth adding that a bigger plan does not fix a latency problem. When someone says “my connection is fast but pages feel slow,” look at latency, DNS and packet loss before blaming bandwidth.
How the same question changes by role
The twenty questions above are common, but interviewers adjust the depth to the job. Click a tab to see what each role is really probing for.
Help desk or IT support
You are the first person someone calls when their laptop cannot reach anything.
What they probe. Expect Questions 3, 9, 10 and 19 in some form. They want a calm method: check the cable or Wi-Fi, look for a 169.254 address, ping the gateway, then a public IP, then a name. Say each step out loud and what a failure at that step would mean.
Network engineer
You design and maintain the switches, routers and links that a company depends on.
What they probe. Expect deep dives into Questions 4, 12, 14 and 15: carve a block into subnets on a whiteboard, explain how a routing table picks a path, how a VLAN trunk works, and what happens when a link fails. Quote real protocols and mention labs you have built.
Backend developer
You write services that talk to databases, APIs and browsers across a network.
What they probe. The URL question (Q11) is almost guaranteed. Be ready for follow-ups on TCP versus UDP, what a timeout or a connection reset means, how DNS caching can cause stale answers after a deploy, and how HTTPS certificates fail. Latency and connection reuse come up often.
DevOps or cloud
You build and run infrastructure in a cloud, where networks are made from settings, not cables.
What they probe. Subnetting and CIDR (Q4) matter a lot, because you will plan address ranges for virtual private clouds. Expect NAT (Q13), firewalls and security groups (Q16), DNS records (Q8), and a scenario such as why a private server cannot reach the internet. The answer often involves a missing route or NAT gateway.
Security analyst
You watch traffic for things that should not be there and harden what is exposed.
What they probe. Expect Questions 7, 10, 16, 17 and 18 with an attacker’s twist: SYN floods, ARP spoofing, why HTTP is unsafe, what a VPN does and does not hide, and how stateful firewalls track connections. Strong answers always state both the attack and the defence.
Common mistakes candidates make
- Reciting definitions with no example. A definition shows memory. An example shows understanding.
- Mixing up layers. Saying a switch “routes” or that IP is at layer 2 is the quickest way to lose credibility.
- Confusing the port with the protocol. Port 443 is conventionally HTTPS, but a program can use any port.
- Forgetting that DNS uses UDP. Most do not mention that TCP is used for large answers and zone transfers.
- Claiming NAT is a firewall. It hides addresses as a side effect. It does not enforce a security policy.
- Guessing in troubleshooting questions. Describe your method out loud. Interviewers care more about how you think than what you land on.
- Bluffing. “I have not used that, but here is how I would find out” works far better than inventing an answer.
A study plan that actually works
If you have two weeks, here is the order I recommend. Spend the first few days on layers, IP, subnets and TCP versus UDP, and practise subnetting by hand until the powers of two come automatically. In the middle days, trace one full web request (Question 11) on paper, then capture a real one using a packet analyser such as Wireshark and watch the DNS query, handshake and TLS hello appear. In the last days, build a small lab. The free Packet Tracer simulator from Cisco Networking Academy is excellent for this, and you can also run a few Linux virtual machines. Break something on purpose, then fix it using the ping ladder.
Nothing replaces hands-on practice. The people who stand out are the ones who say “when I set this up at home, I noticed…” because that cannot be memorised.
Test yourself: five-question mock round
Tap a question to reveal the answer. The correct option is marked.
A /26 network holds how many usable host addresses?
- 64
- 62
- 30
- 254
A /26 has 2^(32-26) = 64 addresses. Two are reserved for the network and broadcast addresses, leaving 62.
Your laptop shows 169.254.12.7 and has no internet. What most likely failed?
- DNS
- The website
- DHCP, so no address was assigned
- TLS
169.254.x.x is the link-local fallback used when no DHCP server answers.
A router has routes for 10.0.0.0/8, 10.1.0.0/16 and 0.0.0.0/0. Where does a packet to 10.1.5.5 go?
- The 10.1.0.0/16 route
- The 10.0.0.0/8 route
- The default route
- It is dropped
All three match, but the longest prefix (/16) is the most specific, so it wins.
Which device forwards frames using MAC addresses?
- Hub
- Router
- Firewall
- Switch
A switch is a layer 2 device that learns MAC addresses and sends each frame only to the right port.
What are the three messages in the TCP handshake, in order?
- SYN, ACK, SYN-ACK
- SYN, SYN-ACK, ACK
- ACK, SYN, SYN-ACK
- SYN-ACK, SYN, ACK
The client sends SYN, the server replies SYN-ACK, and the client finishes with ACK.
Frequently asked questions
How many networking questions should I expect in an interview?
It depends on the role. For a general IT or developer job, expect a handful of fundamentals such as TCP versus UDP, DNS and the URL question. For a network engineer role, expect a long technical session with subnetting, routing and troubleshooting scenarios.
Do I need a certification like CCNA?
It helps for network engineering and support roles because it shows structured knowledge and gives you lab practice. It is rarely required for developer roles, where clear understanding of the basics matters more.
How do I practise without expensive equipment?
Use a free simulator such as Cisco Packet Tracer, run a few virtual machines on your own PC, and capture real traffic with Wireshark. Breaking and fixing a small lab teaches more than reading.
What should I do if I do not know an answer?
Say what you do know, reason from the layers, and say how you would find out. Interviewers value honest thinking much more than a confident wrong answer.
Should I memorise port numbers?
Learn the common ones: 22 SSH, 25 SMTP, 53 DNS, 80 HTTP, 443 HTTPS, 3306 MySQL and 3389 RDP. You do not need hundreds, but you do need those, and the reasoning behind them.
Is the OSI model actually used in real networks?
The internet runs on TCP/IP, but engineers use OSI layer numbers every day as shorthand for where a problem lives. That makes it worth knowing even though it is a reference model, not a protocol stack.
Key takeaways
- Answer in three layers: a one-sentence definition, a real-world picture, then one detail from experience.
- Know the layers cold. Switches are layer 2, routers are layer 3, and TCP and UDP are layer 4.
- Be able to do subnet arithmetic: usable hosts = 2(32 − prefix) − 2, and the longest prefix wins in routing.
- Tell the URL story end to end: DNS, TCP handshake, TLS, HTTP, render.
- For troubleshooting, work from near to far with ping: loopback, gateway, public IP, domain name.
- Practise with a real lab and a packet capture. Hands-on stories beat memorised definitions every time.
