Test Network Segmentation Blocks Lateral Movement
In this article
This guide walks you through testing whether your network segmentation actually stops an attacker from moving laterally from one compromised host to another. You'll simulate a basic attack path, verify that firewall rules and VLANs enforce the boundaries, and learn how to interpret the results. Before you start, make sure you have permission to test the network, a clear scope of what you're allowed to touch, and a rollback plan in case something breaks.
What You'll Need
- Two test hosts (physical or virtual) on different segments—e.g., one in the "trusted" zone, one in the "DMZ" or "guest" zone.
- Administrative access to the firewall, switch, or router that enforces the segmentation.
- A network scanning tool (e.g., Nmap, masscan) and a simple client like Netcat or PowerShell Test-NetConnection.
- A way to capture traffic (e.g., Wireshark) if you want to verify the block at the packet level.
- A documented baseline of what should be allowed and what should be blocked.
Step-by-Step
- Define the expected behavior. Review your segmentation policy. For example, you might expect that the DMZ can initiate outbound HTTP/HTTPS to the internet, but the trusted zone should not be able to initiate any connection to the DMZ. Write down a list of specific ports and protocols that should be blocked.
- Set up your test environment. Place one host on each side of the segment boundary. Ensure they are on different subnets/VLANs and that the firewall is in the path. Record their IP addresses and the default gateway for each.
- Verify basic connectivity within the same segment. From Host A (e.g., the trusted zone), ping Host A's own gateway or another host on the same segment to confirm the network stack is working. This isolates the test to the segmentation rule, not a general network issue.
- Attempt a ping from Host A to Host B (the other segment). This is your first test. If the policy says ICMP should be blocked, a successful ping means the rule is not working. If ICMP is allowed, you'll need to test a specific port that should be blocked.
- Test a specific TCP port that should be blocked. Use a tool like Nmap:
nmap -p 445 --open 192.168.2.10(replace with the actual IP). If the port shows as open, the segmentation is failing. If it shows as filtered or closed, the rule is likely working. Repeat for a few ports that are supposed to be blocked (e.g., 22, 3389, 3306). - Test a port that should be allowed. For example, if the policy allows HTTP from the DMZ to the trusted web server, run a simple HTTP request (e.g.,
curl http://target-ip). This confirms you're not blocking everything—just the lateral movement paths you intend to block. - Attempt a real lateral movement technique. Use a tool like PsExec (Windows) or SSH (Linux) to try to execute a command on the target host. For example, from Host A, try to connect to Host B's admin share:
net use \\192.168.2.10\C$. If it succeeds, the segmentation is not preventing lateral movement. - Check the firewall logs. After each test, look at the firewall logs to see if the traffic was denied. The log should show the source IP, destination IP, port, and the action (allow/deny). This confirms that the block is happening at the firewall, not just that the host is unreachable.
- Test from the other direction. Lateral movement can happen both ways. Repeat steps 4-8 with Host B as the source and Host A as the target, even if your policy says only one direction should be blocked.
- Document your findings. For each test, note the source, destination, port, expected result, actual result, and any relevant log entries. This becomes your evidence that the segmentation is (or isn't) working.
Common Mistakes
- Testing only ICMP. Many firewalls block ping by default, but allow more dangerous ports like 445 or 3389. Always test the actual services that an attacker would use.
- Forgetting to test from the other direction. Segmentation might be one-way. If you only test from A to B, you might miss that B can reach A.
- Ignoring the firewall's stateful inspection. If you allow a connection from B to A, the return traffic from A to B is automatically allowed. Make sure your test accounts for that—for example, if you SSH from B to A, the return SSH traffic from A to B is allowed, but A cannot initiate a new SSH connection to B.
- Not accounting for network address translation (NAT). If the firewall NATs traffic, the source IP in the logs might not match the original host. Check the NAT rules to understand what you're seeing.
- Testing with the wrong tool. A simple ping might be blocked, but a TCP connection could still succeed. Use a tool that tests the actual protocol, not just ICMP.
- Not cleaning up after the test. Leave the test hosts and any temporary rules in place? That's a security risk. Remove any temporary firewall rules and shut down test VMs after you're done.
Tips
- Use a dedicated test VLAN. If possible, create a temporary VLAN for testing so you don't risk disrupting production traffic.
- Start with a simple test, then escalate. First test a single port, then try a full lateral movement tool. This helps you isolate where the failure is.
- Automate the tests. Write a script that runs Nmap against a list of ports and outputs the results. This makes it repeatable and easier to compare before/after changes.
- Test after any firewall change. Whenever you modify segmentation rules, re-run the tests to ensure you didn't accidentally open a path.
- Involve a second person. Have someone else review your test plan and results. They might spot a flaw you missed.
- Use a penetration testing tool like Metasploit to simulate a real attack, but only if you have the expertise and permission. This gives a more realistic assessment.
Troubleshooting
- The test fails (connection succeeds) but the firewall rule looks correct. Check for implicit allow rules. Many firewalls have a default allow rule at the end of the rulebase. Also check for rules on other devices (e.g., a switch ACL) that might be permitting the traffic.
- The test fails (connection times out) but you expected it to be allowed. Check if the destination host's firewall is blocking the traffic. The network segmentation might be working, but the host itself might be down or have its own firewall. Try pinging the host from the same segment to verify it's up.
- You see the traffic in the firewall logs as denied, but the connection still succeeds. This can happen if there's a load balancer or proxy in front of the firewall that forwards traffic without going through the firewall. Trace the full network path.
- Nmap shows the port as "filtered" instead of "closed". This usually means the firewall is dropping the packets, which is a good sign. But it could also mean a network issue. Check the firewall logs to confirm.
- The test works in one direction but not the other. This is normal if your segmentation is one-way. But if you expect both directions to be blocked, check for asymmetric routing or a misconfigured rule.
- You can't get the test hosts on different segments. If you don't have physical hosts, use virtual machines with virtual network adapters connected to different virtual switches. Or use network namespaces in Linux to simulate separate segments on a single host.
Frequently Asked Questions
Is it enough to test with a ping?
No. Ping only tests ICMP, which is often blocked by default. An attacker will use TCP/UDP ports like 445, 22, or 3389. Always test the actual services that matter.
What if the firewall logs show the traffic as denied, but the connection still succeeds?
This usually indicates a bypass path—maybe a secondary link, a VPN, or a misconfigured route. Trace the full path from source to destination to find where the traffic is actually going.
Should I test with real attack tools like Metasploit?
Yes, if you have the skill and permission. Real tools can reveal that a port is open but the service is not exploitable, or that a service is vulnerable despite the port being blocked. However, for a quick check, a port scan is sufficient.
How often should I test segmentation?
At least after any firewall rule change, and ideally on a regular schedule (e.g., quarterly) as part of your security monitoring. Also after network changes like adding a new VLAN or subnet.
What's the difference between a "filtered" and "closed" port in Nmap?
Filtered means the firewall is dropping the packets, so Nmap can't determine if the port is open. Closed means the host responded with a RST, indicating no service is listening. For segmentation testing, filtered is usually what you want to see for blocked ports.
Can I test segmentation without a dedicated test environment?
You can, but it's risky. You might accidentally disrupt production services. If you must test in production, use a low-impact method like a single port scan and ensure you have rollback plans. Ideally, use a staging environment.