# Firewalls and Network Segmentation

> Use stateful firewalls, allow-list rules and network segments so a single compromised machine cannot reach everything else. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/cybersecurity/firewalls-segmentation
Last updated: 2026-11-28

Use stateful firewalls, allow-list rules and network segments so a single compromised machine cannot reach everything else.

Beginner · about 8 hours · difficulty 2/5

Learn first: [Subnetting, Ports and Common Services](https://www.internhack.in/roadmaps/tracks/cybersecurity/subnetting-ports)

A **firewall** decides which traffic is allowed between networks or hosts. **Segmentation** splits a flat network into zones so that trust is not shared by default. Together they limit how far a problem can spread, which defenders call reducing the **blast radius**.

### Key ideas

- **Stateless vs stateful**: a stateful firewall tracks connections, so replies to allowed outbound traffic are permitted automatically.
- **Default deny**: block everything, then allow only the flows the business needs. Rules should name source, destination, port and a reason.
- **Host firewalls** (Windows Defender Firewall, `nftables`/`ufw` on Linux) protect each machine even inside a trusted zone.
- **Zones and VLANs**: separate user laptops, servers, management interfaces, guest Wi-Fi and OT/IoT devices.
- **Egress filtering**: controlling outbound traffic is just as important as inbound, because it limits data exfiltration and malware call-backs.

### How to work with rules

- Keep a rule inventory with an owner and review date for every rule.
- Remove "any/any" rules and temporary rules that became permanent.
- Log denied traffic and review it; unexpected denies often reveal misconfigured or compromised hosts.

### Pitfalls

- Segments that exist on a diagram but are fully routable in reality.
- Management ports (RDP, SSH, admin panels) reachable from user networks.

Good enough to move on: you can design a small network with at least four zones, write the allow rules between them, and explain what each rule is for.

## Key concepts

- **Stateless vs stateful filtering**
- **Default deny and allow-listing**
- **Host firewalls (ufw, nftables, Windows)**
- **VLANs and security zones**
- **Egress filtering**
- **Next-generation firewall features**: App awareness, user identity, URL filtering
- **Rule reviews and hygiene**

## Mini project

Draw a segmented design for a small company (users, servers, management, guest Wi-Fi), write a rule table with justifications, then implement host firewall rules on two lab VMs and prove blocked traffic is logged.

## Check yourself

Why does egress filtering matter even if inbound traffic is locked down tightly?

## Free resources

- [NIST SP 800-41 Rev. 1: Guidelines on Firewalls and Firewall Policy](https://csrc.nist.gov/pubs/sp/800/41/r1/final) (NIST)
- [UFW community documentation](https://help.ubuntu.com/community/UFW) (Ubuntu)
- [Windows Defender Firewall overview](https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/) (Microsoft Learn)

Previous: [IAM Operations and Privileged Access](https://www.internhack.in/roadmaps/tracks/cybersecurity/iam-operations) · Next: [Intrusion Detection and Prevention](https://www.internhack.in/roadmaps/tracks/cybersecurity/ids-ips)

## More in Network Defense

- [Firewalls and Network Segmentation](https://www.internhack.in/roadmaps/tracks/cybersecurity/firewalls-segmentation)
- [Intrusion Detection and Prevention](https://www.internhack.in/roadmaps/tracks/cybersecurity/ids-ips)
- [VPNs and Secure Remote Access](https://www.internhack.in/roadmaps/tracks/cybersecurity/vpn-remote-access)
- [Zero Trust Architecture](https://www.internhack.in/roadmaps/tracks/cybersecurity/zero-trust)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cybersecurity Roadmap](https://www.internhack.in/roadmaps/tracks/cybersecurity)
