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.
You must restrict east-west traffic so developer workstations cannot access the production database subnet in a campus network. Outline a set of router/switch ACLs or firewall rules (include 3-5 example lines), describe where to apply them (source-side/segmentation point), and explain how to allow legitimate admin flows (backups, monitoring) without opening a broad hole.
Sample Answer
Direct answer
Apply an explicit deny from the developer-workstation subnet to the production-database subnet at the router or switch closest to the workstation subnet, so the traffic is contained before it can even cross the rest of the network, and carve out narrow, source-specific allow rules above that deny for the legitimate admin flows, backups and monitoring, that genuinely need reachability.
Structured elaboration
Where to enforce it. Enforcing at the segmentation point closest to the source, the developer subnet's own router or switch interface, is both more efficient (the traffic never crosses the rest of the network before being dropped) and reduces how many places the rule has to be duplicated, compared to trying to enforce it only at the database subnet's edge, where you would have to defend against every possible source rather than just this one.
Example access control list (ACL), illustrative Cisco-style extended ACL syntax, addresses and numbers are illustrative:
! illustrative only: addresses, host counts and port numbers are placeholders
! applied inbound on the developer-workstation VLAN interface (source-side enforcement)
access-list 101 permit tcp host 10.5.1.50 host 10.20.30.10 eq 5432
access-list 101 permit tcp 10.5.1.0 0.0.0.255 host 10.20.30.20 eq 443
access-list 101 deny ip 10.5.1.0 0.0.0.255 10.20.30.0 0.0.0.255
access-list 101 permit ip any any
Where 10.5.1.0/24 is the developer-workstation subnet and 10.20.30.0/24 is the production-database subnet. Line 1 permits one specific backup host (10.5.1.50) to reach the database on its own port (5432, illustrative). Line 2 permits the whole developer subnet to reach a specific monitoring collector (10.20.30.20) on port 443 for metrics traffic, not the database itself. Line 3 is the explicit deny for everything else from the developer subnet into the entire database subnet. Line 4 permits everything else, so the ACL does not accidentally break unrelated developer traffic to destinations outside the database subnet, since Cisco ACLs end in an implicit deny-all if this last line is left out.
Allowing legitimate admin flows without opening a broad hole. Scope each exception to the specific host and the specific port that flow actually needs, a single backup host to the database's own port, not the entire developer subnet to the entire database subnet, and place those specific-host allow rules above the broad deny, since ACLs evaluate top to bottom and the first match wins. Where possible, have the more-trusted side initiate the connection, for example the backup or monitoring system pulling from the database subnet rather than a developer host pushing to it, so the exception's source is a single hardened, single-purpose host rather than an entire pool of developer workstations, any of which could be compromised.
Worked example
Trace three concrete flows through the access control list above. A developer's laptop tries to open a database client directly to the production database: it does not match line 1 or 2 (wrong source and destination), matches line 3 (the broad deny), and is dropped. The designated backup server (10.5.1.50) connects to the database on port 5432: it matches line 1 first, and is allowed. Any developer workstation sends monitoring-agent traffic to the collector on port 443: it matches line 2, and is allowed. The fact that only the exact source-and-destination-and-port combinations in lines 1 and 2 get through, and everything else in that source-to-destination path falls to the deny, is exactly the narrow exception this question is asking for.
Trade-offs and pitfalls
Forgetting line 4, or an equivalent permit-the-rest rule, means the ACL's implicit deny-all silently blocks all other developer traffic to unrelated destinations, a common and hard-to-diagnose authoring mistake. Placing the broad deny above the specific allow rules would mean the deny matches first and the legitimate flows never get evaluated at all, since ACL evaluation stops at the first match. Scoping the backup allow rule to the whole developer subnet instead of a single host would silently widen the exception to any compromised developer machine on that subnet, defeating the entire purpose of the restriction.
You are deploying a network-based IDS for a medium-sized office that has a public DMZ, an internal LAN, and a concentration of remote VPN users. Describe where you would place sensors (tap/span/inline) for maximum visibility, what traffic each sensor should capture (north-south/east-west), how to handle encrypted links, and any network changes (VLANs, mirror ports, taps) required to support reliable packet capture and minimal loss.
Sample Answer
Direct answer
For a medium office with a public DMZ (demilitarized zone: the segment holding internet-facing servers), an internal LAN, and remote VPN users, place a network-based intrusion detection system (NIDS) sensor at three separate vantage points, not one: a mirrored tap on the DMZ switch, a mirrored tap on the internal core switch, and visibility on VPN traffic after it is decrypted. A single sensor at the internet edge would miss internal lateral movement and would only ever see encrypted VPN traffic, so placement has to follow where an attacker could actually be, not just where the internet connection enters.
Sensor placement by zone
- DMZ tap (north-south, public facing): mirror the switch port the public web and mail servers sit on using a SPAN (switched port analyzer) port or a physical network tap. This is your best view of internet-originated exploit attempts against those servers, since DMZ hosts are the most exposed and most frequently probed.
- Internal core tap (east-west, LAN-to-LAN): mirror the core switch so you see traffic between internal workstations and servers, not just traffic leaving the building. Most real intrusions move laterally after an initial foothold, and a sensor watching only the internet edge never sees that movement.
- VPN traffic: a sensor cannot usefully inspect an encrypted VPN tunnel from outside it. Place the sensor to see traffic after the VPN gateway decrypts it, where it rejoins the internal network as plaintext from the network's perspective, and correlate this with VPN gateway logs (which user, which internal IP was assigned) so you keep the user identity that a plain packet capture loses once traffic is de-encapsulated.
- Inline versus tap: you could also insert a sensor inline, directly in the traffic path, instead of on a mirrored copy. That trades a small amount of added latency and a new failure point in the path for the ability to later promote the same sensor from pure detection to active blocking without moving it. For a first deployment in an office that cannot afford dropped production traffic, mirrored tap or SPAN placement out of the path is the lower risk starting point; inline placement is worth revisiting once the signatures are proven reliable.
Below is the layout. Dashed lines are mirrored copies of traffic sent to the sensors, not traffic paths.
flowchart LR
Internet((Internet)) --> EdgeRouter[Edge router / border firewall]
EdgeRouter --> DMZswitch[DMZ switch with SPAN port]
DMZswitch --> WebSrv[Public web/mail servers]
DMZswitch -. mirrored traffic .-> IDS_DMZ[NIDS sensor: DMZ tap]
EdgeRouter --> InternalFW[Internal firewall]
InternalFW --> CoreSwitch[Core switch with SPAN port]
CoreSwitch --> LAN[Internal LAN hosts]
CoreSwitch -. mirrored traffic .-> IDS_LAN[NIDS sensor: internal tap]
Internet --> VPNGW[VPN gateway, inline]
VPNGW -- decrypted traffic --> InternalFW
VPNGW -. post-decrypt mirror .-> IDS_VPN[NIDS sensor: post-decryption tap]
IDS_DMZ --> SIEM[(SIEM)]
IDS_LAN --> SIEM
IDS_VPN --> SIEM
Required network changes
A NIDS sees only what is actually delivered to it, so getting one to work reliably usually means:
- Configuring SPAN or mirror ports on each switch that needs a sensor. A heavily loaded switch can silently drop mirrored frames under load before a hardware tap would, so a physical tap is preferable on the busiest link, typically the DMZ uplink.
- Segmenting the office into VLANs (virtual LANs) if it is currently flat, both so the DMZ, LAN, and management traffic can be mirrored independently and so a compromise in one zone does not trivially reach the others.
- Sizing the sensor's network interface and CPU for full duplex mirrored throughput, since a SPAN port often aggregates both directions of traffic onto one physical link, which can exceed that link's own rated speed on a busy switch.
If the DMZ servers also run host-based agents (host-based intrusion detection, or HIDS), tune each sensor type for what it is actually good at: the DMZ hosts' HIDS should watch for local file and process tampering since those servers are the most exposed, while the network taps are tuned for exploit signatures and traffic anomalies crossing each boundary. Treating both as one undifferentiated detection layer and tuning them identically wastes the host agent's unique visibility into what happened on the box itself.
Trade-offs and pitfalls
The most common mistake is placing a single sensor at the internet edge and calling the office covered: that setup is blind to anything that happens once an attacker is already inside the DMZ or LAN, which is exactly where the more damaging part of most intrusions occurs. A second common mistake is trying to feed a NIDS the encrypted VPN tunnel directly, which produces zero useful signatures; the decrypt point is a hard requirement, not an optimization.
Explain the differences between AWS Security Groups and Network ACLs. Include differences in statefulness, rule evaluation order, directionality, use cases, and limitations. Provide an example where you would use both together for layered protection.
Sample Answer
Direct answer
An AWS Security Group is a stateful, instance-level firewall, attached to the elastic network interface, that only supports allow rules. A Network Access Control List (Network ACL) is a stateless, subnet-level firewall that supports both explicit allow and explicit deny rules evaluated in numbered order. The two are commonly layered together: the Network ACL as a coarse, subnet-wide boundary, and Security Groups as fine-grained, per-resource control.
Structured elaboration
| Property | Security Group | Network ACL |
|---|---|---|
| Statefulness | Stateful; return traffic is automatically allowed | Stateless; each direction needs its own explicit rule |
| Scope | Attached to the network interface or instance | Attached to the subnet, applies to everything inside it |
| Rule types | Allow only; anything unlisted is implicitly denied | Explicit Allow and explicit Deny |
| Evaluation | All matching rules apply; there is no ordering | Rules evaluated in numbered order, first match wins |
| Typical use | Fine-grained, per-resource access control | Coarse, subnet-wide boundary or an explicit block |
| Key limitation | Cannot explicitly block one specific bad actor by rule | No statefulness, so every allowed direction needs its own rule |
Worked example
A layered database subnet: a Network ACL rule at a low rule number (for example, rule 90, Deny) explicitly blocks a known-malicious address range before a broader allow rule further down (rule 100, Allow, for the virtual private cloud's own address range) is ever reached. That gives you the one capability Security Groups cannot provide on their own: an explicit block that still applies even if a future Security Group misconfiguration would otherwise have let that traffic through. Meanwhile, the database instances' own Security Group allows inbound traffic on the database port only from the application tier's Security Group specifically, giving fine, per-resource control that the subnet-wide Network ACL cannot express, since a Network ACL can only say "from this address range," never "from this specific application tier."
Trade-offs and pitfalls
Because Network ACLs are stateless, a very common mistake is allowing inbound traffic on a port but forgetting the matching outbound rule for the ephemeral return ports, which silently breaks connections that otherwise look correctly configured. Network ACL rule numbering matters because the first matching rule wins, so an accidentally low-numbered, overly broad allow rule can shadow a more specific deny rule placed after it. Relying on Network ACLs alone for fine-grained, per-application control does not work well, since they apply to an entire subnet, not one resource. Relying on Security Groups alone means there is no way to explicitly block one specific known-bad address, since Security Groups have no deny rule at all.
Write a Suricata or Snort rule that triggers on DNS TXT responses larger than 512 bytes and containing base64-like characters (indicative of tunnel/exfil). Include the exact rule syntax, explain each part (header, options, content modifiers), and discuss potential evasion techniques and strategies to reduce false positives.
Sample Answer
Approach
Detecting DNS TXT-record tunneling from the wire, without a full DNS-aware application-layer parser, means using two proxy signals that correlate strongly with tunneling: an oversized DNS response, and a long run of base64-like characters in the payload. Plain DNS over UDP is capped at 512 bytes by the original DNS specification; modern DNS commonly negotiates larger UDP messages through an extension called EDNS0, so large alone is not automatically malicious, but a large response combined with a long base64-looking string is a much stronger, more specific signal.
alert udp any 53 -> $HOME_NET any (msg:"POLICY DNS response oversized with high-density base64-like payload, possible TXT record tunneling or exfiltration"; flow:to_client; dsize:>512; pcre:"/[A-Za-z0-9+\/]{40,}={0,2}/"; classtype:policy-violation; sid:1000301; rev:1; reference:url,attack.mitre.org/techniques/T1071/004/;)
Explaining each part
alert udp any 53 -> $HOME_NET any: the header. Action alert, protocol UDP, source any host on port 53, a DNS server whether legitimate or attacker-controlled, destination your protected network on any port, matching a DNS response coming back in.flow:to_client;: restricts the match to the response direction, since a large base64-like response from a DNS server is the exfiltration or tunneling signal, not the typically small query going out.dsize:>512;: matches on the UDP payload size exceeding the classic non-EDNS0 DNS limit; this is the unusually-large heuristic.pcre:"/[A-Za-z0-9+\/]{40,}={0,2}/": a Perl-compatible regular expression looking for a run of 40 or more base64-alphabet characters, optionally followed by up to two padding characters, the shape a base64-encoded exfiltration payload embedded in a TXT record's text tends to take.classtype:policy-violation;: this is a heuristic, policy-style detection rather than a signature for one specific known exploit, so it is classified accordingly.reference:url,attack.mitre.org/techniques/T1071/004/;: points to MITRE ATT&CK technique T1071.004, Application Layer Protocol: DNS, the standard reference for DNS used as a command-and-control or exfiltration channel.
False positives and evasion
The most realistic false-positive source is legitimate large TXT records that also look like base64: DKIM (DomainKeys Identified Mail, an email authentication standard) public keys published in DNS TXT records are themselves base64-encoded and can be long, and SPF (Sender Policy Framework, another email authentication standard) records with many included domains can also grow large. Expect to tune with an allowlist for known-legitimate high-volume TXT-serving domains, such as your own mail domains, rather than relying on this rule alone for blocking. An attacker aware of this heuristic can evade it by staying under the size and character-run thresholds and using more, smaller queries instead of fewer, larger ones, trading a slower exfiltration rate for reduced detection risk; catching that requires the aggregate, log-based investigation approach, looking at query volume and entropy over time per domain, rather than a single-packet rule.
Edge cases
- This rule only fires on UDP; a resolver that fails over to DNS over TCP for large responses, which happens automatically once a response would be truncated over UDP, would not match this specific rule, so a production deployment should mirror it with a TCP port 53 equivalent.
- The 40-character threshold is a tunable starting point, not a verified production value; tune it against your own traffic's normal TXT record sizes before deploying in blocking mode.
Describe man-in-the-middle (MITM) attacks including passive interception and active manipulation techniques (e.g., ARP spoofing, TLS stripping). Explain which network and application-layer logs and telemetry you would examine to detect MITM activity and provide two immediate mitigations for a corporate network.
Sample Answer
A man-in-the-middle (MITM) attack is when an attacker inserts themselves between two communicating parties, either just observing the traffic (passive interception) or actively changing it (active manipulation), without either legitimate party realizing a third party is involved.
Passive vs active techniques
- Passive interception: the attacker taps traffic without altering it, for example by mirroring a switch port, running a rogue access point, or using ARP spoofing purely to redirect traffic through themselves for silent capture. This is a confidentiality violation only.
- Active manipulation: the attacker changes what each side sees.
- ARP spoofing (ARP poisoning): since the Address Resolution Protocol has no authentication, the attacker sends forged ARP replies mapping a real IP (often the default gateway) to the attacker's own MAC address, so victim traffic is routed through the attacker.
- TLS stripping: the attacker sits between the client and server and intercepts the client's initial plaintext HTTP request before it upgrades to HTTPS, keeping the client on cleartext HTTP while the attacker proxies the real connection to the server over HTTPS. The user's browser shows a working connection, but everything between the client and attacker is unencrypted.
Detection telemetry
- Network layer: ARP table and gateway-MAC monitoring (one MAC suddenly claiming an IP it never has, or the gateway's MAC changing), unsolicited/gratuitous ARP replies, rogue DHCP (Dynamic Host Configuration Protocol) servers, switch port-security violations, and traceroute or latency anomalies suggesting an extra hop.
- Application layer: certificate mismatches or downgrade attempts in browser/proxy logs, requests arriving over plain HTTP where HTTPS was expected, violations of HTTP Strict Transport Security (HSTS) policy, and session tokens being used from two different IP addresses or user agents within seconds of each other.
Worked example
Attacker on the same LAN as the victim broadcasts a gratuitous ARP reply: "10.0.0.1 (the gateway) is at AA:BB:CC:DD:EE:FF (attacker's NIC)." The victim's ARP cache updates, so all of the victim's gateway-bound traffic now flows through the attacker first. If the switches run Dynamic ARP Inspection (DAI) against a DHCP-snooped IP-to-MAC binding table, that same forged reply is compared to the trusted binding, found not to match, and dropped and logged instead of being accepted, which is exactly the detection signal described above.
Two immediate mitigations
- Enable Dynamic ARP Inspection plus DHCP snooping on access switches, so ARP replies are validated against a trusted binding table and spoofed ones are dropped at the switch.
- Enforce HSTS and disable any HTTP fallback on externally reachable services, so a stripping attempt has no plaintext path to downgrade to.
Trade-offs and pitfalls
Dynamic ARP Inspection only protects the Layer 2 segment it is deployed on, it does nothing for MITM happening outside your own switches (a public Wi-Fi hotspot, for example). HSTS only protects repeat visits unless the domain is preloaded in browsers, so there is a first-visit gap. Detection controls alone (without prevention) still leave a real exposure window between the attack starting and someone acting on the alert.
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.