Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Enforce Zero Network Egress & Test It

· 4 min read · Home Networking

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Zero network egress means no outbound traffic is allowed from your workloads, preventing data exfiltration and limiting attack surface. This guide shows how to enforce it using cloud security groups, host-based firewalls, and network policies, then how to verify it with simple tests. You'll need access to the environment you're securing and the ability to run commands.

What You'll Need

  • Admin access to your cloud console (AWS, Azure, GCP) or on-prem firewall
  • SSH access to a test instance or container
  • Basic command-line knowledge (curl, nc, iptables, or cloud CLI)
  • Optional: a network monitoring tool (e.g., tcpdump, Wireshark)

Step-by-Step

  1. Identify all egress paths. List every network interface, route, and service that can send traffic. In cloud, check VPC route tables, security groups, and NAT gateways. On a host, run ip route and netstat -rn.
  2. Create a deny-all outbound policy. In cloud security groups, remove all outbound rules (or set to deny). For host-based, use iptables or nftables: iptables -P OUTPUT DROP (then allow only loopback). For Kubernetes, apply a NetworkPolicy with egress: [].
  3. Apply the policy to all resources. Attach the security group to every instance, or apply the network policy to all pods. For on-prem, update the firewall rules on the edge.
  4. Test from inside. SSH to a test instance and try curl -I https://example.com or nc -zv 8.8.8.8 53. Both should fail with a timeout or connection refused.
  5. Test from outside. From a separate network, try to connect to a service on the instance (e.g., SSH port 22). It should still work if inbound is allowed—this confirms you only blocked egress.
  6. Verify with monitoring. Use tcpdump -i eth0 (or cloud flow logs) to confirm no outbound packets are seen. Capture for a few minutes while generating test traffic.
  7. Automate the check. Write a script that periodically attempts an outbound connection and alerts if it succeeds. Use cron or a cloud function.
  8. Document and review. Record the policy, the test results, and any exceptions (e.g., allow specific IPs for updates). Review quarterly.

Common Mistakes

  • Forgetting to also block DNS (UDP 53) and DHCP—these are often allowed by default.
  • Only blocking HTTP/HTTPS but leaving other ports open (e.g., SSH, SMTP).
  • Not applying the policy to all instances—new instances may inherit a permissive default.
  • Testing from the same subnet as the instance, which might bypass some network ACLs.
  • Confusing inbound and outbound rules—make sure you're editing the correct direction.

Tips

  • Use a dedicated test instance that you can break without affecting production.
  • Start with a logging rule (e.g., LOG in iptables) before dropping to see what's being blocked.
  • For cloud, use managed policies (e.g., AWS Security Groups, Azure NSG) rather than host firewalls for consistency.
  • If you need to allow specific egress (e.g., to a database), create a separate security group with only those rules and attach it to that resource.
  • Test after any change to the environment—new subnets, new services, or updates can introduce egress.

Troubleshooting

  • Outbound still works after applying policy. Check if there's a NAT gateway or proxy that bypasses the security group. Also verify the policy is attached to the correct network interface.
  • Inbound breaks as well. You may have accidentally modified the inbound rules or the default policy. Review all rules and revert if needed.
  • DNS fails but other traffic is blocked. If you need DNS, allow UDP/TCP 53 to your DNS server's IP only, not to all destinations.
  • Instance can't reach the internet for updates. That's expected—you'll need to allow specific update endpoints or use a proxy that is explicitly permitted.
  • Monitoring shows no packets, but tests succeed. Your tests might be using a cached connection or a different interface. Use curl --interface eth0 or check routing.
  • Kubernetes NetworkPolicy not working. Ensure your CNI supports it (e.g., Calico, Cilium). Also check if there are multiple policies that combine—the most restrictive wins.

Frequently Asked Questions

  • Can I allow only specific IPs? Yes, create a security group or firewall rule that allows outbound to those IPs only, and deny all others.
  • Does zero egress affect inbound connections? No, inbound and outbound are separate. You can still receive traffic, but your instance cannot initiate connections.
  • What about ICMP (ping)? ICMP is often blocked by default. If you need it for monitoring, allow it explicitly, but it's not required for zero egress.
  • How do I test from a container? Use docker exec to run a curl or nc command inside the container. The same steps apply.
  • Will this break automatic updates? Yes, unless you allow specific update servers. Plan for that by whitelisting necessary endpoints.
  • Is zero egress suitable for all workloads? No, some applications need to call external APIs or send telemetry. Use it for sensitive data stores or isolated environments.