Network Security Interview Questions: Cryptography, Firewalls and Attacks
Last updated 2026-11-19
Network security questions test both vocabulary and reasoning. Expect to compare symmetric and asymmetric encryption, explain how TLS combines them, describe attacks such as SYN flood, ARP spoofing and DNS poisoning, and say what a firewall or IDS can and cannot stop. Written papers also include small numericals on Diffie-Hellman key exchange and RSA, which this page solves step by step.
This page is for the networking side of security; for application-level flaws like SQL injection see the backend and web guides. It builds on HTTP and HTTPS interview questions for TLS and on TCP/IP interview questions for the attacks on the protocol. For preparation see how to crack a computer networks interview.
| Numericals | Diffie-Hellman exchange, RSA encrypt and decrypt, password entropy and brute-force time |
|---|---|
| Covered | CIA triad, crypto basics, TLS, firewalls, IDS/IPS, VPN, attacks, hardening |
| Questions | 17 |
Defence in depth in one paragraph
No single control is enough, so layers are combined: network segmentation and firewalls limit reach, encryption protects data in transit, strong authentication limits who can connect, patching removes known flaws, and logging with monitoring detects what was missed. When asked how to secure a system, answer by layer and name the threat each control addresses.
Network Security Interview Questions: questions with worked answers
1 What is the CIA triad?
easyConfidentiality means only authorised parties can read data (encryption, access control). Integrity means data is not altered without detection (hashes, digital signatures, MACs). Availability means services are usable when needed (redundancy, DDoS protection, backups). Every attack and control maps to at least one of the three: ransomware hits availability, a man-in-the-middle hits confidentiality and integrity.
2 Compare symmetric and asymmetric encryption.
easySymmetric encryption (AES, ChaCha20) uses the same key to encrypt and decrypt: it is fast and suits bulk data, but both sides must share the key securely. Asymmetric encryption (RSA, elliptic curve) uses a public key to encrypt and a private key to decrypt, so no secret needs to be shared beforehand, but it is hundreds of times slower and encrypts only small amounts. Real protocols such as TLS use asymmetric methods to agree on a key and symmetric encryption for the data.
3 What is a hash function? How do hashing, encryption and encoding differ?
mediumA cryptographic hash (SHA-256) maps any input to a fixed-size digest, is one-way, deterministic, and makes it infeasible to find collisions or invert it. Encryption is reversible with the key and protects confidentiality. Encoding such as Base64 is a reversible format change with no secret and no security. Hashes check integrity and store passwords; MD5 and SHA-1 are broken for security use.
4 How should passwords be stored?
mediumNever store plaintext or a plain fast hash. Use a slow, salted, purpose-built password hashing function such as Argon2id, scrypt or bcrypt. A unique random salt per user defeats rainbow tables and makes identical passwords hash differently, and the work factor makes each guess expensive. Compare with a constant-time check.
pythonimport hashlib, os, hmac salt = os.urandom(16) h = hashlib.scrypt(b"s3cret-pass", salt=salt, n=2**14, r=8, p=1, dklen=32) # store salt + h; to verify, recompute with the stored salt ok = hmac.compare_digest(h, hashlib.scrypt(b"s3cret-pass", salt=salt, n=2**14, r=8, p=1, dklen=32)) print(ok) # True5 What is a digital signature and how does it differ from encryption?
mediumA sender hashes the message and encrypts the hash with their private key, producing the signature. Anyone with the public key verifies it by decrypting the signature and comparing with the hash of the received message. This proves integrity, authenticity and non-repudiation, but not confidentiality, since the message itself is not encrypted. Encryption does the opposite: the public key encrypts and only the private key can decrypt.
6 Numerical: Diffie-Hellman with p = 23, g = 5. Alice's secret is a = 6 and Bob's is b = 15. Find the public values and the shared secret.
mediumAlice sends A = g^a mod p = 5^6 mod 23. 5^2 = 25 = 2, 5^4 = 4, 5^6 = 5^4 x 5^2 = 8. So A = 8. Bob sends B = 5^15 mod 23: 5^8 = 4^2 = 16, so 5^15 = 5^8 x 5^4 x 5^2 x 5 = 16 x 4 x 2 x 5 = 640 mod 23 = 19 (since 27 x 23 = 621). So B = 19. Alice computes B^a = 19^6 mod 23: 19 is -4 mod 23, so (-4)^6 = 4096 mod 23 = 2 (178 x 23 = 4094). Bob computes A^b = 8^15 mod 23 = 2^45; as 2^11 = 2048 = 89 x 23 + 1 so 2^11 is 1 mod 23, and 2^45 = 2^(44 + 1) = 2. Shared secret = 2. An eavesdropper sees only p, g, A and B and must solve a discrete logarithm.
7 Numerical: RSA with p = 3, q = 11, e = 7. Find n, the private exponent d and encrypt then decrypt m = 4.
mediumn = p x q = 33. phi = (p - 1)(q - 1) = 2 x 10 = 20. e = 7 is coprime to 20. d is the inverse of 7 mod 20: 7 x 3 = 21 = 1 mod 20, so d = 3. Encrypt: c = m^e mod n = 4^7 mod 33. 4^2 = 16, 4^3 = 64 mod 33 = 31, 4^6 = 31^2 = 961 mod 33 = 4 (961 - 957), so 4^7 = 4 x 4 = 16. Decrypt: m = c^d mod n = 16^3 = 4096 mod 33 = 4 (33 x 124 = 4092). It matches. Real keys use primes of 1024 bits or more, so factoring n is infeasible.
8 Numerical: A password is 8 characters from a 62-symbol set (a-z, A-Z, 0-9). Find the entropy and the time to try every password at 10^9 guesses per second.
mediumCombinations = 62^8 = 2.18 x 10^14. Entropy = 8 x log2(62) = 8 x 5.954 = 47.6 bits. Time to try all = 2.18 x 10^14 / 10^9 = 218,000 s, about 2.5 days (on average half of that). That is feasible for an attacker with a fast hash, which is why long passphrases, slow hashes and rate limiting matter: each extra character multiplies the work by 62.
9 Explain the types of firewalls.
mediumA packet-filtering firewall decides per packet on source and destination address, port and protocol, and is fast but unaware of connections. A stateful firewall tracks connection state, so it allows return traffic for outbound connections and blocks unsolicited inbound packets. A proxy or application-layer firewall terminates connections and inspects application content, such as a web application firewall for HTTP. Next-generation firewalls add deep inspection, user identity and intrusion prevention. A default-deny rule set is the safe baseline.
10 What is the difference between an IDS and an IPS?
mediumAn intrusion detection system watches traffic or hosts and raises alerts when it sees signatures or anomalies; it sits out of band (on a mirror port), so it cannot disrupt traffic but cannot block either. An intrusion prevention system sits in line and can drop the packets or reset connections. IPS stops attacks automatically but a false positive blocks legitimate traffic, and an in-line failure affects availability.
11 What is a VPN and how does it work?
mediumA virtual private network creates an encrypted tunnel across an untrusted network so remote users or sites appear to be on a private network. Packets are encapsulated and encrypted at the entry point (IPsec at layer 3, OpenVPN or WireGuard over TLS or UDP) and decrypted at the exit. Site-to-site VPNs link offices, and remote-access VPNs connect individual users. A VPN protects the traffic in transit, not the endpoint at either side.
12 Explain the man-in-the-middle attack, ARP spoofing and how to prevent them.
mediumIn a man-in-the-middle attack the attacker secretly relays and possibly alters communication between two parties. On a LAN, ARP spoofing sends forged ARP replies, so victims map the gateway's IP to the attacker's MAC and send traffic through the attacker. Defences are TLS with certificate validation (and HSTS), dynamic ARP inspection and port security on switches, static ARP for critical hosts, and VPNs on untrusted networks.
13 What is a DDoS attack and how do you mitigate it?
mediumA distributed denial of service attack floods a target with traffic from many compromised machines until legitimate users cannot be served. Types include volumetric floods, protocol attacks such as SYN flood and application-layer floods like many HTTP requests. Reflection and amplification attacks use spoofed sources to make open DNS or NTP servers send large responses to the victim. Mitigation includes rate limiting, SYN cookies, over-provisioned capacity, CDN and scrubbing services, anycast and filtering spoofed traffic at the edge.
14 What are XSS, CSRF and SQL injection in one line each, and how are they prevented?
mediumSQL injection puts attacker text into a database query: prevented by parameterised queries. Cross-site scripting makes a page run attacker JavaScript in the victim's browser: prevented by output encoding and a content security policy. Cross-site request forgery makes a logged-in browser send an unwanted request: prevented by anti-CSRF tokens and SameSite cookies. They are application-layer, so a network firewall alone does not stop them. See DBMS interview questions for SQL.
15 How does TLS provide security in HTTPS, and what happens if a certificate is invalid?
mediumThe server proves its identity with a certificate signed by a trusted authority, the two sides agree on session keys with an ephemeral key exchange, and data is encrypted and authenticated with a symmetric cipher, giving confidentiality, integrity and server authentication. If the certificate is expired, issued for another name or signed by an untrusted authority, the browser warns, since this may be an interception. Clicking through removes the authentication guarantee.
16 What is the difference between authentication, authorisation and accounting?
hardAuthentication verifies who you are (password, one-time code, key, biometric), authorisation decides what you may do once identified (roles, ACLs), and accounting records what you did (logs, audit trails). Multi-factor authentication combines something you know, something you have and something you are. Protocols such as RADIUS and TACACS+ implement all three for network devices.
17 What is zero trust, and how does it differ from perimeter security?
hardPerimeter security trusts everything inside the network boundary and defends the edge with a firewall and VPN, so one compromised internal host can move laterally. Zero trust assumes no implicit trust based on network location: every request is authenticated, authorised and encrypted using identity, device health and context, with least-privilege access and microsegmentation. It suits cloud and remote work, where there is no clear perimeter.
Frequently asked questions
What is the difference between a virus, a worm and a trojan?
A virus attaches to a program and spreads when it is run. A worm spreads by itself across networks without user action. A trojan pretends to be legitimate software and relies on the user to install it, often to open a backdoor.
What is a zero-day vulnerability?
A flaw unknown to the vendor, with no patch available, that may already be exploited. Mitigation relies on layered controls, monitoring and quick patching once a fix appears.
What is the difference between HTTPS and a VPN?
HTTPS encrypts the traffic of one application connection and authenticates the website. A VPN encrypts all traffic from a device to the VPN endpoint and hides it from the local network, but the destination can still see you as the VPN exit.
What is a honeypot?
A decoy system that looks vulnerable to attract attackers, so defenders can study their methods and detect intrusions early. Any traffic to it is suspicious by definition.
Related guides
- HTTP and HTTPS Interview Questions: Methods, Status Codes, TLS and Caching
- TCP/IP Interview Questions: Handshake, Congestion Control and Numericals
- DNS Interview Questions: Resolution, Record Types, Caching and Troubleshooting
- Computer Networks Interview Questions with Worked Answers and Numericals
- OSI Model Interview Questions: Layers, PDUs, Devices and Encapsulation
- IP Addressing and Subnetting Interview Questions with Worked Solutions
- Linux Interview Questions and Answers: Concepts, Permissions and Processes
More in CS Fundamentals Interview Questions
- Normalization Interview Questions with Worked Examples
- NoSQL Interview Questions and Answers
- OOPs Interview Questions and Answers
- Operating Systems Interview Questions with Worked Answers
- OSI Model Interview Questions: Layers, PDUs, Devices and Encapsulation
- Paging and Virtual Memory Interview Questions with Numericals
- Process and Thread Interview Questions with fork() Output Problems
- Process Synchronization Interview Questions: Semaphores, Mutex and Classic Problems
- Redis Interview Questions and Answers
- REST API Interview Questions and Answers
- Routing Protocols Interview Questions: RIP, OSPF, BGP and Shortest Path Examples
- SDLC and Agile Interview Questions