December Code

Hub, switch and router interview questions, with answers

Questions about network devices check whether you can connect the layer model to real equipment: what each device looks at, what it forwards, and how it divides a network. They come up in networking rounds and in system design, where load balancers, proxies and firewalls are the building blocks.

The answers below cover hubs, switches and routers, collision and broadcast domains, gateways, firewalls, load balancers, forward and reverse proxies, and modems. Then take the free Computer Networks diagnostic — ten questions across every networking topic in the bank — to see which of these you can explain but not yet apply.

The questions, with answers

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

    In short: A hub repeats bits to every port, a switch forwards frames by MAC address, and a router forwards packets between networks by IP address.

    A hub works at the physical layer: whatever arrives on one port is repeated to all the others, so every device shares the bandwidth and collisions are possible. A switch works at the data link layer: it forwards each frame only to the port where the destination MAC address is, giving each port its own bandwidth and allowing full duplex. A router works at the network layer: it connects different IP networks, chooses paths using its routing table, and separates broadcast domains. Hubs are obsolete; switches build LANs, and routers connect them to each other and to the internet.

  2. 2.What are collision domains and broadcast domains?

    In short: A collision domain is where simultaneous transmissions collide; a broadcast domain is where a broadcast frame reaches every device.

    A collision domain is a network segment in which two devices transmitting at the same time interfere. Every port of a hub shares one collision domain, while each switch port is its own, and full-duplex links have no collisions at all. A broadcast domain is the set of devices that receive a layer 2 broadcast, such as an ARP request, from any one of them. Switches forward broadcasts, so everything behind them is one broadcast domain unless VLANs split it, while routers do not forward broadcasts, so each router interface bounds one. Large broadcast domains waste bandwidth on broadcast traffic.

  3. 3.What is a default gateway?

    In short: The router on a host's local network that it sends every packet destined for another network to.

    A host can deliver packets directly only to addresses on its own subnet. For any other destination, it sends the packet to its default gateway, the local router's address, which it learns from DHCP or manual configuration. The host resolves the gateway's MAC address with ARP and addresses the frame to it, while the packet keeps the final destination's IP address. The router then forwards it onwards. A wrong or missing gateway is a classic fault: local communication works, but nothing outside the subnet can be reached.

  4. 4.What does a firewall do, and what is a stateful firewall?

    In short: A firewall filters traffic by rules; a stateful one tracks connections, so replies to allowed traffic pass without separate rules.

    A firewall sits between networks and allows or blocks traffic according to rules on addresses, ports, protocols and, in more advanced firewalls, application content. A stateless packet filter judges each packet in isolation, so rules must explicitly allow return traffic. A stateful firewall keeps a table of active connections, so once an outgoing connection is allowed, its replies are recognised and let in automatically while unsolicited incoming packets are dropped. Next-generation firewalls add application awareness and intrusion prevention. Host firewalls apply the same idea on individual machines.

  5. 5.What is a load balancer, and how do layer 4 and layer 7 load balancers differ?

    In short: It spreads incoming requests across servers; layer 4 decides by addresses and ports, layer 7 by HTTP content such as paths.

    A load balancer receives client traffic and distributes it across a pool of servers, improving capacity and availability: it health-checks the servers and stops sending traffic to failed ones. A layer 4 load balancer works with TCP or UDP connections and chooses a server from addresses and ports, without looking inside, which is fast and protocol-agnostic. A layer 7 load balancer understands HTTP, so it can route by URL path, host name, headers or cookies, terminate TLS and keep a user on the same server. Common algorithms are round robin, least connections and hashing on the client address.

  6. 6.What is the difference between a forward proxy and a reverse proxy?

    In short: A forward proxy acts for clients reaching out to servers; a reverse proxy sits in front of servers and acts for them toward clients.

    A forward proxy sits on the client side: clients send their requests to it and it fetches from the internet on their behalf, which organisations use to filter, log or cache traffic, and which hides the client's address from the server. A reverse proxy sits in front of servers: clients connect to it as if it were the server, and it forwards requests to the right backend, adding TLS termination, caching, compression, load balancing and protection for the servers behind it. nginx and HAProxy are commonly used as reverse proxies, and CDNs are distributed reverse proxies.

  7. 7.What is the difference between a modem and a router?

    In short: A modem converts between the ISP's line signal and digital data; a router connects the home network to it and directs traffic.

    A modem, modulator-demodulator, translates between the signal used on the ISP's medium, such as DSL, cable or fibre (where an ONT does this job), and the digital Ethernet signal a computer understands; it gives one connection to the ISP's network. A router connects the devices of a local network to that connection: it forwards packets between the LAN and the ISP, usually runs DHCP for the local devices, and often provides Wi-Fi and a firewall. Home devices usually combine modem, router, switch and access point in one box, which is why the two are often confused.

How the diagnostic asks it

One question from the Computer Networks bank, exactly as a sitting would show it. The bank has 3 on network devices and 30 across Computer Networks.

Network Devices · easyCN-024

An 8-port switch with no VLANs connects 8 computers. How many collision domains and broadcast domains are there?

  1. 11 collision domain and 8 broadcast domains
  2. 21 collision domain and 1 broadcast domain
  3. 38 collision domains and 1 broadcast domaincorrect
  4. 48 collision domains and 8 broadcast domains

A switch gives each port its own collision domain, so 8 ports means 8 collision domains, and with full duplex there are no collisions at all. It forwards broadcasts out of every port, though, so all 8 computers share 1 broadcast domain. 1 collision domain is what a hub gives, since a hub repeats every signal to every port. Separating broadcast domains needs a router or VLANs, which is why neither option with 8 broadcast domains fits a single switch.

Measure it

Reading answers tells you what’s true. A diagnostic tells you what you get wrong.

10 Computer Networks questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.

What the readiness test measures · how the score is computed

By Harshit · updated