Loading...
Loading...
Core CS and SQL interview guide
OSI and TCP/IP, IP addressing, TCP and UDP, DNS and HTTP. Every answer is short enough to say aloud, and every question links to the lesson that teaches it.
60 questionsLast updated
TLS is the newer, secure successor of SSL. All SSL versions are broken and disabled; people still say "SSL certificate", but the protocol in use is TLS 1.2 or 1.3.
Lesson: HTTP vs HTTPS, ports and common protocolsIt is a signed document that binds a domain name to a public key, issued by a certificate authority. The browser trusts it if the signature chain leads to a root CA in its trust store and the name and dates are valid.
Lesson: HTTP vs HTTPS, ports and common protocolsThe client says hello with the TLS versions and ciphers it supports. The server replies with its choice and its certificate. They use asymmetric key exchange to agree on a shared secret, derive symmetric session keys and switch to encrypted traffic.
Follow-up: When is the certificate checked? Right after the server sends it, before any key is agreed. If the check fails, the browser shows a warning and the connection should not continue.
Lesson: HTTP vs HTTPS, ports and common protocolsAsymmetric cryptography solves the problem of agreeing a key with a stranger and proving identity, but it is slow. Symmetric encryption is fast, so once both sides share a key, all the data uses it.
Follow-up: Why not use asymmetric encryption for all the data? It is far slower and uses more CPU than symmetric encryption, so TLS uses it only to authenticate and agree on a key.
Common mistake: Calling one of them "better". They solve different problems: identity and key exchange versus fast bulk encryption.
Lesson: HTTP vs HTTPS, ports and common protocolsAn attacker sits between the user and the server and reads or changes traffic. With HTTPS, the attacker cannot present a valid certificate for the real domain, so the browser shows a warning instead of silently connecting.
Follow-up: What if the user clicks through the certificate warning? Then the protection is gone and the attacker's fake certificate is accepted. That is why the warning must never be ignored.
Lesson: HTTP vs HTTPS, ports and common protocolsA port is a 16-bit number from 0 to 65535 that identifies a service on a host. Ports 0 to 1023 are well-known ports for standard services like 22 SSH and 443 HTTPS; clients use random high ephemeral ports.
Lesson: HTTP vs HTTPS, ports and common protocolsFTP 20 and 21, SSH 22, SMTP 25 (587 for submission), DNS 53, HTTP 80, HTTPS 443, MySQL 3306.
Follow-up: Which of those are encrypted by default? SSH (22) and HTTPS (443). FTP (21), SMTP (25), HTTP (80) and plain MySQL traffic are not, unless wrapped in TLS.
Lesson: HTTP vs HTTPS, ports and common protocolsPort 21 carries the control connection for commands like login and list, and a separate data connection, port 20 in active mode or a negotiated port in passive mode, carries the files.
Lesson: HTTP vs HTTPS, ports and common protocolsSFTP is a file transfer protocol that runs over SSH on port 22. FTPS is classic FTP wrapped in TLS. Both encrypt; SFTP is simpler through firewalls because it uses one connection.
Lesson: HTTP vs HTTPS, ports and common protocolsPOP3 downloads mail to one device and usually deletes it from the server. IMAP keeps mail on the server and syncs read status and folders across phone and laptop, which is why it is the common choice today.
Follow-up: Which one would you use on a phone and a laptop? IMAP, so both devices see the same mailbox. POP3 downloads the mail to one device and usually removes it from the server.
Lesson: HTTP vs HTTPS, ports and common protocolsIt keeps the TCP connection open after a response so the next request can reuse it, saving the TCP and TLS handshakes. It is the default in HTTP/1.1.
Lesson: HTTP vs HTTPS, ports and common protocolsHTTP/2 keeps the same methods, headers and status codes but uses binary framing, multiplexes many requests over one connection and compresses headers. This removes the need for many parallel connections.
Follow-up: Does your Spring Boot code change for HTTP/2? No. The server and the browser negotiate the version, so your controllers stay the same.
Lesson: HTTP vs HTTPS, ports and common protocolsHTTP/3 runs HTTP over QUIC, which is built on UDP and includes TLS 1.3. Losing one packet blocks only its own stream instead of the whole connection, and connection setup is faster.
Lesson: HTTP vs HTTPS, ports and common protocolsThe form data, including the password, would travel unencrypted, and browsers warn about it as mixed content. The form action must use https, and the site should send HSTS so browsers never use plain HTTP.
Follow-up: How would you fix it? Change the form action to https://, and add HSTS and a redirect from http to https, so credentials never travel in clear text.
Common mistake: Saying "the page is https, so it is fine". The password goes wherever the form action points.
Lesson: HTTP vs HTTPS, ports and common protocolsA hub is a layer 1 device that repeats any signal it receives to all other ports. All devices share the bandwidth and one collision domain, so hubs are obsolete now.
Lesson: Routers, switches and basic network securityA router is a layer 3 device that connects different networks and forwards packets by destination IP address using its routing table.
Follow-up: What does a router do with a packet it cannot route? It uses the default route if there is one. Otherwise it drops the packet and sends back an ICMP destination unreachable message.
Lesson: Routers, switches and basic network securityA hub repeats bits to every port at layer 1. A switch forwards frames by MAC address to one port at layer 2. A router forwards packets between networks by IP address at layer 3.
Follow-up: Which one connects your home to the internet? A router, usually combined with a modem, switch and access point in one box. The router joins your LAN to the ISP's network.
Common mistake: Comparing them by speed or price. Compare them by layer, the address they read and what they do with traffic.
Lesson: Routers, switches and basic network securityA gateway is the device a network uses to reach other networks. In a home or hostel, the default gateway is the router's LAN address, such as 192.168.1.1.
Lesson: Routers, switches and basic network securityA modem converts signals between your ISP line (fibre, cable or DSL) and Ethernet. A router directs traffic between your local network and the internet, usually with NAT, DHCP and Wi-Fi. Many home boxes combine both.
Follow-up: Where does the modem fit? The modem converts the ISP's signal (cable, fibre or DSL) to Ethernet. The router then shares that single connection between your devices.
Lesson: Routers, switches and basic network securityA wireless access point connects Wi-Fi devices to a wired network. It works at layer 2, like a switch for wireless clients.
Lesson: Routers, switches and basic network securityIt reads the source MAC of every incoming frame and records it against the port it came in on. If a destination MAC is unknown, it floods the frame and learns the location from the reply. Entries age out after a few minutes.
Follow-up: What happens when a device moves to another port? Old entries age out after a timeout and the device is learned again on its new port. If an attacker fills the table (MAC flooding), the switch floods like a hub.
Lesson: Routers, switches and basic network securityIt is a list of network prefixes with the next hop or interface for each. The router picks the longest prefix that matches the destination, and uses the default route 0.0.0.0/0 when nothing else matches.
Follow-up: What is the default route? The entry 0.0.0.0/0, which matches anything not matched by a longer prefix. It sends the traffic to the ISP or the next router.
Lesson: Routers, switches and basic network securityStatic routes are typed in by an administrator and do not change on their own. Dynamic routing protocols such as OSPF and BGP let routers share routes and adapt when links fail; BGP connects the networks that make up the internet.
Lesson: Routers, switches and basic network securityA LAN covers a building or campus, a MAN covers a city, and a WAN connects distant sites across countries. The internet is the largest WAN.
Lesson: Routers, switches and basic network securityA VLAN is a logical network created on a switch, so ports on the same switch can belong to different broadcast domains. It separates groups like students and staff for security and less broadcast traffic, without buying separate switches.
Follow-up: Is a VLAN a security feature? It separates traffic, which helps, but real security needs firewall rules between the VLANs. A VLAN alone does not replace a firewall.
Common mistake: Saying a VLAN needs a separate cable. It is a logical separation on shared hardware.
Lesson: Routers, switches and basic network securityThey need a layer 3 device: a router or a layer 3 switch, often with firewall rules deciding what traffic may cross.
Lesson: Routers, switches and basic network securityIt tracks active connections, so return traffic for a connection started from inside is allowed automatically, while unrequested incoming traffic is blocked. A stateless filter checks each packet alone.
Follow-up: Why is a stateful firewall better than a packet filter? It tracks connections, so replies to your requests are allowed automatically and unrequested incoming traffic is blocked without a rule for every port.
Lesson: Routers, switches and basic network securityA DMZ is a separate network zone for public-facing servers such as a website. The firewall lets the internet reach the DMZ but not the internal network, so a hacked web server does not expose everything.
Lesson: Routers, switches and basic network securityA VPN creates an encrypted tunnel from your device to a VPN server. Companies use it so employees can reach internal systems safely from home; users also use it to protect traffic on public Wi-Fi.
Follow-up: What is the difference between a VPN and HTTPS? HTTPS encrypts one connection to one website. A VPN encrypts everything between your device and the VPN server and makes you appear inside that network.
Common mistake: Saying a VPN encrypts the whole path to the website. It protects only the tunnel to the VPN server.
Lesson: Routers, switches and basic network securityNo. It hides your traffic from the local network and your ISP, but the VPN provider can see it, and websites can still identify you through logins and cookies.
Lesson: Routers, switches and basic network securityA forward proxy acts for clients, for example a college proxy that filters and caches students' web access. A reverse proxy acts for servers, for example Nginx in front of app servers doing load balancing, TLS termination and caching.
Follow-up: Give a real example of a reverse proxy. Nginx in front of Spring Boot instances: it ends TLS, balances load and hides the real servers from clients.
Lesson: Routers, switches and basic network securityA denial of service attack floods a service so real users cannot use it. A DDoS uses many machines, often a botnet, so blocking one IP does not help.
Follow-up: Why can a simple block not stop a DDoS? The traffic comes from thousands of different IPs, so blocking one address does nothing. You need rate limiting and large-scale filtering.
Lesson: Routers, switches and basic network securityPut it behind a CDN or DDoS protection service that absorbs traffic, add rate limiting and firewall rules, and design the app to scale. Very large attacks must be filtered upstream, before they reach your servers.
Lesson: Routers, switches and basic network securityThe attacker secretly sits between two parties, reading and possibly changing their traffic, for example through a fake Wi-Fi hotspot or ARP spoofing. HTTPS with proper certificate checks is the main defence.
Follow-up: How does HTTPS stop it? The attacker cannot present a valid certificate for the real domain, so the browser warns the user, and the encrypted data is useless to the attacker.
Lesson: Routers, switches and basic network securityPhishing uses fake messages or websites that look real to steal passwords, OTPs or card details. Check the real domain in the link, never share OTPs or PINs, and turn on multi-factor authentication.
Follow-up: What do you do after clicking a phishing link? Enter nothing, close the page, change the password if you typed one, turn on multi-factor authentication and report the message.
Common mistake: Answering only "I never click suspicious links". Give checks: the real domain, the sender, the urgency, and never sharing an OTP.
Lesson: Routers, switches and basic network securityIt is sending packets with a fake source IP address. It is used in DoS attacks and reflection attacks; ISPs filter packets whose source addresses cannot come from their customers.
Lesson: Routers, switches and basic network securityUsually a firewall or a forward web proxy at the campus edge. It can block by domain name in DNS or in the TLS server name, by IP address, or by URL category in the proxy.
Lesson: Routers, switches and basic network securityPut it in a private subnet behind a load balancer or reverse proxy, open only 443 to the internet, allow SSH only from a VPN or a fixed admin IP, and keep the database port 3306 reachable only from the app servers.
Follow-up: Which ports would you open? Only 443 (and 80 for a redirect) to the public, SSH on 22 limited to your own IP, and the database port 3306 open only to the app server.
Common mistake: Leaving the database port open to the internet. A database should be reachable only from the application servers.
Lesson: Routers, switches and basic network securityPhysical, Data Link, Network, Transport, Session, Presentation, Application.
Follow-up: Which layers do you use most as a backend developer? Layers 3, 4 and 7: IP addresses, TCP or UDP ports, and the HTTP application protocol. I debug top-down from layer 7 and bottom-up from layer 1.
Common mistake: Reciting the layers in the wrong order. Start from the bottom: Physical, Data Link, Network, Transport, Session, Presentation, Application.
Lesson: Practice: networks rapid-fire and subnetting drillApplication, Transport, Internet and Network Access (also called Link).
Lesson: Practice: networks rapid-fire and subnetting drillSegment at transport, packet at network, frame at data link.
Follow-up: Which layer adds a trailer? The data link layer. The frame ends with a frame check sequence used to detect errors.
Common mistake: Calling every unit a packet. Segment belongs to transport, packet to network and frame to data link.
Lesson: Practice: networks rapid-fire and subnetting drill10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
Lesson: Practice: networks rapid-fire and subnetting drill/25 has 126 usable hosts and /28 has 14.
Follow-up: Show the working for a /28. 32 minus 28 is 4 host bits. 2 to the power 4 is 16 addresses, and minus 2 leaves 14 usable hosts.
Common mistake: Answering with the totals (128 and 16). Subtract 2 for the network and broadcast addresses.
Lesson: Practice: networks rapid-fire and subnetting drill255.255.248.0.
Lesson: Practice: networks rapid-fire and subnetting drillThe all-zeros address is the network address and the all-ones address is the broadcast, so neither can be given to a device.
Lesson: Practice: networks rapid-fire and subnetting drillIt finds the MAC address for an IP address on the same local network by broadcasting a request.
Follow-up: What if the target is on another network? The host ARPs for the default gateway's MAC instead, and the router carries on from there.
Lesson: Practice: networks rapid-fire and subnetting drillAn IP address, subnet mask, default gateway and DNS server, leased for a set time, using Discover, Offer, Request and Acknowledge.
Lesson: Practice: networks rapid-fire and subnetting drillClient SYN with sequence x, server SYN-ACK with sequence y and ack x+1, client ACK with ack y+1.
Follow-up: What does the third segment do? The client's ACK confirms the server's starting number (ack y+1). After it, both sides know the other can send and receive.
Lesson: Practice: networks rapid-fire and subnetting drillFlow control protects the receiver using its advertised window; congestion control protects the network using the congestion window.
Follow-up: Which window does each control use? Flow control uses the receive window (rwnd) set by the receiver; congestion control uses the congestion window (cwnd) kept by the sender.
Lesson: Practice: networks rapid-fire and subnetting drillUDP: DNS queries and video calls. TCP: web browsing over HTTP/1.1 or HTTP/2, and SSH.
Follow-up: Why not use UDP for a bank transfer? Lost or reordered messages could corrupt the transfer unless the app rebuilt reliability itself. TCP already provides it.
Lesson: Practice: networks rapid-fire and subnetting drillA for IPv4, AAAA for IPv6, CNAME for an alias, MX for mail servers.
Lesson: Practice: networks rapid-fire and subnetting drillHTTPS is HTTP inside a TLS connection, so the data is encrypted, protected from changes and sent only to a server that proved its identity with a certificate. It uses port 443 instead of 80.
Lesson: Practice: networks rapid-fire and subnetting drillA logical LAN on a switch that is its own broadcast domain, used to separate groups like students and staff.
Lesson: Practice: networks rapid-fire and subnetting drillA firewall allows or blocks traffic by rules. A VPN creates an encrypted tunnel to a remote network.
Lesson: Practice: networks rapid-fire and subnetting drillA server that sits in front of application servers and handles load balancing, TLS and caching for them, such as Nginx.
Lesson: Practice: networks rapid-fire and subnetting drillAn attacker secretly relays traffic between two parties; HTTPS with certificate checks stops it from being silent.
Lesson: Practice: networks rapid-fire and subnetting drillDNS: the name is not being resolved. I would check with nslookup and try another resolver.
Follow-up: Which command do you run next? nslookup or dig for the name, to see whether the DNS server answers.
Common mistake: Blaming the website. When a ping by IP works, the network path is fine.
Lesson: Practice: networks rapid-fire and subnetting drillIt has exactly two usable addresses, one for each end of the link.
Follow-up: What can replace a /30 on such links? A /31, which is allowed on point-to-point links and saves two more addresses.
Lesson: Practice: networks rapid-fire and subnetting drillParse, cache, DNS, TCP, TLS, request, server, render.
Lesson: Practice: networks rapid-fire and subnetting drillPolitely: "I think UDP does not guarantee delivery or order; it has no ACKs or retransmission. TCP is the one that guarantees delivery."
Follow-up: What does UDP provide, then? Ports and a checksum. No ordering, no retransmission and no connection.
Common mistake: Agreeing to be polite. Correct the statement calmly, with one reason.
Lesson: Practice: networks rapid-fire and subnetting drillEach lesson has quizzes, practice and more interview questions on the same topic.
Open the first lesson