Network Security and Defense Questions
Securing networks at the infrastructure layer. Covers firewalls, ACLs and rule design, network device hardening and secure configuration, intrusion detection and prevention systems, VPN and remote-access encryption, network protocols and their security properties, and packet-level traffic analysis. The hands-on network-defense layer, distinct from zero-trust architecture strategy.
Compare insecure protocols (for example: Telnet, FTP, HTTP) with their secure alternatives (SSH, SFTP/SCP, HTTPS). For each insecure/secure pair, describe what confidentiality and integrity protections are missing in the insecure version and outline a migration strategy (short-term mitigation and long-term replacement) that an Information Security Analyst should follow.
Sample Answer
Several widely-deployed legacy protocols transmit everything, including credentials, in plaintext, and each has a secure, encrypted successor that should replace it. The right approach to migration is a short-term compensating control paired with a tracked long-term replacement, not an instant rip-and-replace that a legacy environment often cannot support on day one.
The pairs
| Insecure | Secure alternative | What is missing |
|---|---|---|
| Telnet | SSH (Secure Shell) | No encryption at all (credentials and session content are plaintext) and no server authentication, so a man-in-the-middle can impersonate the host; SSH encrypts the full session and authenticates the server via host keys. |
| FTP (File Transfer Protocol) | SFTP or SCP (both run over SSH) | Credentials and file contents sent in plaintext, and a separate control/data channel model that is awkward to firewall safely; SFTP/SCP inherit encryption and integrity checking from the underlying SSH transport. |
| HTTP | HTTPS (HTTP over TLS) | No confidentiality for request or response bodies and cookies, and no integrity check, so a network attacker can alter content in transit undetected; HTTPS adds encryption and a certificate chain that authenticates the server and reveals tampering. |
Migration strategy per pair
- Telnet to SSH: short-term, restrict Telnet to an isolated management network with strict access control and close monitoring if some legacy device firmware cannot be upgraded immediately; long-term, disable the Telnet daemon entirely and enforce SSH-only management.
- FTP to SFTP/SCP: short-term, confine any remaining FTP service to internal-only networks and never expose it to the internet; long-term, migrate transfer scripts and workflows to SFTP and decommission the FTP service.
- HTTP to HTTPS: short-term, add an HTTP-to-HTTPS redirect and obtain a valid TLS certificate; long-term, enforce HTTPS-only with HTTP Strict Transport Security (HSTS) so browsers refuse to fall back to plaintext even if an attacker tries to intercept the initial redirect.
Worked example
An analyst runs a network scan and finds 40 internal hosts still answering on port 23 (Telnet) and 12 legacy file servers on port 21 (FTP), while the customer-facing website already redirects HTTP to HTTPS. Short-term mitigation applied immediately: a firewall rule restricts ports 23 and 21 to the management subnet only, cutting exposure to the general LAN and internet to zero without waiting for a change window. Long-term: a tracked migration ticket per host group targets a move to SSH and SFTP with a decommission date, and any device whose firmware genuinely cannot be updated in time gets its own documented compensating control (isolation plus logging) rather than being quietly left exposed.
Trade-offs and pitfalls
Some embedded or legacy hardware genuinely cannot support SSH or TLS, so isolation is a legitimate interim step, not an excuse to defer the migration indefinitely. And enabling HTTPS without also enforcing a redirect and HSTS still leaves the plaintext path reachable, which defeats much of the purpose of migrating in the first place.
Explain the difference between a capture filter (libpcap/BPF) and a display filter in Wireshark/tshark. Provide one example capture filter that limits what is written to disk and one example display filter that isolates HTTP GET requests in a saved pcap. Explain when to use capture filters versus display filters.
Sample Answer
A capture filter decides which packets get written to disk (or memory) in the first place; a display filter decides which of the packets you already have get shown to you. They use different syntaxes and operate at different points in the pipeline.
Capture filters
Capture filters use Berkeley Packet Filter (BPF) syntax, the same compact expression language tcpdump uses, and they are compiled into a small program that the operating system's packet-capture layer evaluates per packet at line rate, before anything is written out. Because that filtering happens so early, BPF can only match on lower-layer fields it can cheaply parse: addresses, ports, protocol, packet length. It cannot look inside an HTTP request.
Example capture filter, limiting what gets written to disk to only TCP traffic on port 80:
tcp port 80
Used with tcpdump: tcpdump -i eth0 'tcp port 80' -w capture.pcap
Display filters
Display filters use Wireshark/tshark's own filter language and run against packets that are already fully captured and loaded (from a live capture buffer or a saved pcap). Because the filter runs after capture, it can inspect any layer Wireshark has dissected, including application-layer fields like an HTTP method.
Example display filter, isolating HTTP GET requests in a saved pcap:
http.request.method == "GET"
Applied with tshark: tshark -r capture.pcap -Y 'http.request.method == "GET"'
When to use which
Use a capture filter when you need to control data volume or disk usage at capture time, on a busy link, in a long-running capture, or when you already know exactly what traffic matters and want to discard everything else before it ever touches disk. Use a display filter when you are analyzing data you already have and want to narrow the view without discarding anything, since you can always loosen or change a display filter and see packets you previously hid, but you can never recover packets a capture filter silently dropped.
Compare SNMP v1/v2c with SNMPv3 from a security standpoint. Explain the risks associated with community strings, how SNMPv3 addresses confidentiality and authentication, and the operational considerations and migration steps for moving a large device fleet from v2c to v3.
Sample Answer
Direct answer
SNMPv1 and SNMPv2c authenticate with a "community string," effectively a shared clear-text password sent in every packet with no encryption. SNMPv3 replaces that with per-user authentication (a keyed hash proving both origin and integrity) and optional encryption of the payload, plus fine-grained authorization over which parts of the device's data a given user can even see.
Structured elaboration
- The community-string risk: the string travels unencrypted inside the SNMP packet, so anyone who can sniff the network segment can read it. Devices are frequently left on default strings ("public" for read, "private" for read-write), there is no per-user accountability since everyone with the string looks identical to the device, and if the string grants write access, an attacker who captures it can read and modify device configuration, not just monitor it.
- How SNMPv3 addresses this, via the User-based Security Model (USM):
- Authentication: a per-user keyed hash (SHA is preferred over the legacy MD5 option) proves each message's origin and that it was not altered in transit.
- Privacy (confidentiality): an optional encryption layer (AES is preferred over the legacy DES option) hides the payload from anyone sniffing the wire.
- These combine into three selectable security levels: noAuthNoPriv, authNoPriv, and authPriv (the recommended level for anything beyond a fully trusted lab network).
- Authorization: View-based Access Control (VACM) restricts which specific management-information-base (MIB) objects a given user or group can read or write, instead of v1/v2c's all-or-nothing, community-wide access.
- Migration steps for a large device fleet, v2c to v3:
- Inventory every current community string and every tool (monitoring system, trap receiver, ad hoc script) that polls each device, and confirm every one of those consumers actually supports SNMPv3, which is often the real blocker, not the devices themselves.
- Design the USM user/group model (which auth and privacy algorithms, which users map to which teams or functions, which VACM views each needs) before touching a single device.
- Run a dual-stack pilot: configure SNMPv3 users alongside the existing v2c community on a small representative group of devices, and confirm polling, alerting, and trap delivery all still work end to end.
- Roll out fleet-wide through configuration automation, verifying each device is successfully answering v3 queries before disabling v2c on that specific device, not on the fleet as a whole at once.
- Disable v2c (remove the community strings entirely) only once every consumer is confirmed migrated, then rotate or retire the old strings so they cannot be reused if they leak later.
- On an ongoing basis, rotate SNMPv3 credentials periodically and audit for any device that is still silently answering v2c queries, which is a sign of configuration drift creeping back in.
Worked example
An SNMPv1/v2c GET request carries the community string as a plain ASN.1 octet string inside a UDP/161 packet, with no encryption layer at all. An attacker on the same network segment sniffing that packet reads the string directly (say, "public"), then reuses it to walk the device's entire MIB tree. If that same string also happens to be configured for write access (a common misconfiguration when "private" is left at its default), the attacker can issue an SNMP SET to change something like an interface's administrative status or a routing parameter, using nothing more than a passively captured plaintext value.
Trade-offs and pitfalls
- Disabling v2c before every legacy monitoring consumer has actually migrated does not just create a security gap, it creates a monitoring blind spot, which is often worse in the moment than the risk the migration is trying to fix.
- SNMPv3's authPriv mode adds per-packet cryptographic overhead; usually negligible on modern hardware, but worth checking on old or embedded devices with limited CPU headroom.
- Community strings cannot be rotated invisibly across a fleet; anything still depending on the old value will break the instant it changes, which is exactly why the staged, dual-run migration above is not optional shortcut-taking, it is the actual safe path.
Assume a continuous NetFlow stream that cannot be fully stored. Propose an efficient streaming algorithm and data structure to compute the top-k talkers by bytes with bounded memory. Explain memory complexity, error bounds, how to merge partial results across collectors, and how to handle flow merges/splits.
Sample Answer
Direct answer
For a NetFlow (Cisco's protocol and record format for exporting summarized per-flow traffic statistics from a router or switch, as opposed to full packet capture) stream too large to store in full, use a fixed-size streaming summary rather than an exact hash map: either the Space-Saving algorithm, which tracks a small number of running counters directly, or a Count-Min Sketch (CMS) paired with a small min-heap. Both trade exact counts for a provable error bound in exchange for memory that stays constant no matter how many distinct flows or how much traffic the stream carries, and both support merging partial summaries from multiple collectors into one global view.
Structured elaboration
Problem shape. There are N distinct flow keys (typically the 5-tuple: source IP, destination IP, source port, destination port, protocol), a memory budget M that must stay far below N, and the goal is the true top-k flows by cumulative bytes, with a bounded amount of estimation error tolerated instead of exact counts.
Approach A: Space-Saving. Maintain exactly m counters, m modestly larger than k (see the worked example below for why the margin matters). On seeing an event (flow, byte_weight):
- if the flow already has a counter, add byte_weight to it;
- else if a counter slot is free, create one with count equal to byte_weight;
- else evict the counter with the smallest current count, and give the new flow that slot with count equal to the evicted count plus byte_weight, remembering the evicted count as this flow's maximum possible overestimate.
Guarantee: for a stream whose flows sum to W total bytes,
error(f)≤mWmeaning any flow whose true byte total exceeds W divided by m is guaranteed to still be tracked, and any surviving estimate is never more than W divided by m too high. Flows below that threshold may or may not survive.
Approach B: Count-Min Sketch plus a min-heap. A CMS is a small two-dimensional array of counters updated by several independent hash functions per event, so every insert or query touches only a handful of cells regardless of how many distinct flows exist. Its accuracy is tunable through the array's width and depth: a wider array tightens the error bound, more hash rows raise the confidence that the bound holds. A CMS alone only estimates a given key's count; it does not track which keys are currently largest, so pair it with a small min-heap of the current top-k candidates to avoid scanning every distinct key.
Memory complexity. Both approaches use a fixed, chosen-up-front amount of memory, O(m) counters for Space-Saving or O(width times depth) cells for a CMS, independent of both N and the length of the stream. That constant-memory property is the entire reason to use a sketch instead of a hash map that would otherwise grow with N.
Merging partial results across collectors. This is where the two approaches diverge. A CMS merges exactly: since it is a linear counter array, summing two CMS instances built with the same hash functions and dimensions produces precisely the sketch you would get from feeding both streams into one, with no error added by the merge itself. Space-Saving's merge is approximate: for a flow key both summaries tracked, add the counts; for a key only one summary tracked, add the other summary's current minimum counter value as a conservative stand-in for what that flow might have been, then keep only the top m entries by the combined estimate. This is real and usable, a central NetFlow aggregator can fold in partial summaries from many collectors without reprocessing raw records, but it further loosens the error bound compared to a single non-distributed summary.
Handling flow merges and splits. A single logical connection can generate several separate NetFlow export records over its life, since routers periodically flush active flows on a timer and also flush on connection end or idle timeout. Because both structures update by adding each event's byte weight to that key's running estimate rather than treating every export record as an independent flow, this reassembly is automatic as long as you key consistently on the flow's identifying tuple, and decide once, consistently, whether to treat the two directions of a connection as one flow or two.
Worked example
Running the Space-Saving algorithm with m equal to 3 counters against a small pinned stream of ten flow events:
def space_saving_topk(stream, m):
"""
stream: list of (flow_id, byte_weight) events.
m: number of counters retained, should be set well above k,
the number of top talkers actually wanted (see interpretation below).
Returns {flow_id: [estimated_bytes, max_overestimate]}.
"""
counters = {}
for flow_id, weight in stream:
if flow_id in counters:
counters[flow_id][0] += weight
elif len(counters) < m:
counters[flow_id] = [weight, 0]
else:
evict_id = min(counters, key=lambda k: counters[k][0])
evict_count, _ = counters.pop(evict_id)
counters[flow_id] = [evict_count + weight, evict_count]
return counters
stream = [
("A", 100), ("B", 50), ("C", 30), ("D", 20), ("A", 80),
("E", 60), ("B", 40), ("F", 10), ("A", 20), ("C", 15),
]
m = 3
total_bytes = sum(w for _, w in stream)
result = space_saving_topk(stream, m)
print(f"Total bytes seen: {total_bytes}, counters kept: {m}")
print(f"Guaranteed error bound (total/m): {total_bytes / m:.1f}")
for flow_id, (count, err) in sorted(result.items(), key=lambda kv: -kv[1][0]):
print(f"{flow_id}: estimated_bytes={count}, max_overestimate={err}")
Output:
Total bytes seen: 425, counters kept: 3
Guaranteed error bound (total/m): 141.7
A: estimated_bytes=200, max_overestimate=0
C: estimated_bytes=115, max_overestimate=100
E: estimated_bytes=110, max_overestimate=50
The exact totals for comparison, computed with a plain running sum per flow over the same stream, are A=200, B=90, E=60, C=45, D=20, F=10. A's estimate is exact because it never got evicted. E's estimate of 110 is 50 over its true 60, exactly matching the guaranteed bound. C's estimate of 115 is 70 over its true 45, comfortably inside the 100-byte bound it inherited at eviction time. But notice B, the true second-largest talker at 90 bytes, does not appear in the final top-3 at all: it was evicted along the way and its weight got folded into another flow's inflated count instead.
Interpretation. With W equal to 425 total bytes and m equal to 3 counters, the theoretical retention guarantee only reaches flows above W divided by m, about 141.7 bytes. Only A clears that bar, so only A's presence is actually guaranteed. Everything else, including the true runner-up B, sits below the guarantee threshold, and the algorithm is free to keep or drop any of them, which is exactly what happened. This is the concrete case for sizing m well above k rather than just above it: with k equal to 2 desired talkers and m equal to only 3 counters, there was no headroom for the guarantee to reach past the single largest flow.
Trade-offs and pitfalls
Undersizing m relative to k, exactly what the worked example shows, silently drops real top-k members with no error signal at query time; size m to several multiples of k, not exactly k or k plus one. A CMS's clean linear mergeability makes it the better fit for a highly distributed architecture with many collectors merging on a schedule; Space-Saving's tighter per-key bound and lower memory-per-guarantee makes it the better fit for a single collector or a small number of them. Both structures only estimate byte volume correctly if you feed them the byte weight per event; incrementing by one per NetFlow record instead gives top-k by record count, not by bytes, a common mix-up when repurposing an off-the-shelf sketch library. Neither structure signals when it is wrong: unlike an exact hash map there is no built-in flag that a given estimate crossed its error bound, so any dashboard built on these summaries should surface the theoretical bound alongside the estimate, not just the number.
Design a scalable remote-access VPN architecture to support 50,000 concurrent users across multiple regions with strict availability and throughput SLAs. Describe authentication architecture, session brokering and load balancing, regional ingress/egress placement, key management, NAT and edge constraints, client performance considerations, and telemetry for large-scale troubleshooting. Discuss protocol choices (TLS-based VPN, WireGuard, IPsec) and sharding/federation strategies for auth services.
Sample Answer
Direct answer
At 50,000 concurrent users across regions, treat authentication and tunnel termination as two separately-scaled problems: federate and shard the identity layer so no single authentication service is a global bottleneck, terminate tunnels at regional points of presence close to each user rather than backhauling everyone to one location, and pick the tunnel protocol based on per-session overhead and how gracefully it handles a client moving networks, favoring WireGuard (or a WireGuard-based concentrator) over classic Internet Protocol security (IPsec)/Internet Key Exchange (IKE) for this profile, with a Transport Layer Security (TLS)-based fallback for restrictive networks.
Structured elaboration
flowchart TB
U[Remote users] --> DNS[Geo DNS or anycast broker]
DNS --> R1[Region A concentrators]
DNS --> R2[Region B concentrators]
R1 --> AUTH1[Region A auth front end]
R2 --> AUTH2[Region B auth front end]
AUTH1 --> IDP[Central identity provider]
AUTH2 --> IDP
R1 --> APPS[Internal resources]
R2 --> APPS
- Protocol choice. IPsec/IKE is standard and broadly supported, but its per-session negotiation state and rekey overhead add up at very large concurrent-session counts, and it recovers slowly when a client's network changes (Wi-Fi to cellular). A TLS-based VPN benefits from looking like ordinary HTTPS through almost any firewall, but still carries a full TCP-plus-TLS stack's overhead per session. WireGuard keeps minimal per-connection state (a peer is just a public key mapped to allowed IP ranges, with nothing to renegotiate), runs over UDP, and updates a peer's known address automatically when a valid packet arrives from a new source, which handles client roaming gracefully. Recommendation: WireGuard for the bulk of traffic, with a TLS-based VPN fallback for legacy clients or networks that only permit outbound HTTPS.
- Authentication architecture, sharding and federation. A single centralized authentication service handling all 50,000 users' logins and periodic re-authentication would be both a bottleneck and a single point of failure. Instead, deploy regional authentication front ends that validate short-lived tokens locally, issued by a central identity provider through a federated protocol such as OpenID Connect against the corporate identity system, so only the relatively infrequent token-issuance step reaches the central service, while the frequent per-connection check is a local signature verification, not a network round trip. Shard session state by region so a regional outage affects only users natively assigned there.
- Session brokering and load balancing. A lightweight broker, DNS-based geolocation routing or anycast, directs each client to its nearest regional concentrator cluster. Within a region, a load balancer distributes new connections using a metric that reflects real capacity (concurrent-session count and crypto throughput), since a concentrator's limit is sessions and crypto work, not raw request rate.
- Regional ingress and egress placement. Terminate tunnels close to users to minimize setup and ongoing latency. Egress placement is a separate decision driven by where internal resources actually live: if those resources are centralized, each regional point of presence needs a fast backbone path back to them, which is exactly where the split-tunnel decision below has the largest impact.
- Split tunneling versus forced tunneling. Split tunneling routes only traffic destined for internal resources through the VPN and lets everything else, general browsing, video calls, other software-as-a-service traffic, go directly out the client's own connection. Forced tunneling routes all client traffic through the VPN and out corporate egress regardless of destination. Split tunneling dramatically reduces the bandwidth and latency load on the VPN infrastructure, at 50,000 concurrent users this is often the difference between a feasible and infeasible egress capacity requirement, but it means corporate controls like web filtering, data-loss-prevention inspection and centralized logging never see that split-off traffic, a real visibility trade-off, not just a performance one. Forced tunneling preserves full visibility but multiplies concentrator and egress bandwidth by however much non-corporate traffic each client generates, usually the larger cost driver at this scale. A common middle ground is split tunneling with a defined, audited exception list.
- Key management. WireGuard's per-peer static keypairs (or IPsec certificates) need a provisioning and rotation pipeline tied to the same identity system as authentication: issue a new keypair when a device is enrolled through mobile device management, revoke it promptly when a device or user is deprovisioned. Regional concentrators need a fast path to learn about revocations, since a compromised or terminated-employee device staying valid for hours across every region is a meaningful exposure window.
- NAT and edge constraints. WireGuard and IPsec both need UDP to reach the concentrator, which some restrictive corporate, hotel or airport networks block or throttle. A fallback path over TCP port 443 needs to exist for clients on those networks, at some cost to the primary protocol's throughput and latency advantages.
- Client performance considerations. Keepalive intervals need tuning against mobile battery life (frequent keepalives keep NAT mappings alive but drain battery faster) versus how quickly a dead session is detected and failed over. WireGuard's cheap, stateless handshake is an advantage here: a client can drop and rejoin cheaply compared to a heavier IKE renegotiation.
- Telemetry for large-scale troubleshooting. Per-region dashboards of concurrent sessions, tunnel-setup latency (P50/P95/P99, the 50th/95th/99th percentile), and concentrator resource utilization; per-user session history recording which regional point of presence, connect and disconnect times, and disconnect cause (client-initiated, keepalive timeout, server-side eviction); and aggregate authentication latency and failure rate split by region, so a regional identity-provider or network issue shows up as an isolated regional anomaly rather than a confusing global one.
Worked example
50,000 concurrent users spread evenly across 4 regions averages 12,500 sessions per region. If each concentrator instance is rated for a conservative 3,000 concurrent WireGuard sessions (a modest figure given WireGuard's small per-session footprint), a region needs
⌈3,00012,500⌉=5 instances at steady state
plus at least one more for N+1 redundancy, six instances per region, twenty-four total, a number the capacity-planning and autoscaling policy should be built around directly rather than discovered after an outage.
Trade-offs and pitfalls
WireGuard's lightweight scaling and roaming behavior come at the cost of some of the enterprise tooling maturity (granular per-application policy, specific compliance certifications) that established IPsec or SSL-VPN (the older industry name for a TLS-based VPN) products have accumulated, worth weighing explicitly for a highly regulated industry. Sharding authentication by region improves resilience but means a traveling user either needs to reauthenticate against the new region's front end or the token-validation public keys need to already be replicated everywhere, an easy detail to miss until someone travels and gets locked out.
Unlock Full Question Bank
Get access to all Network Security and Defense interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.