Rules that block unwanted traffic, and a private tunnel across the public internet.
A firewall is a gatekeeper that allows or blocks network traffic using rules. A VPN (Virtual Private Network) is an encrypted tunnel that carries your traffic safely across a network you do not trust.
A firewall sits between networks (the internet and your servers, or one subnet and another) and checks traffic against a list of rules. A rule usually names a source, a destination, a port, a protocol (TCP, UDP) and an action (allow or deny).
A stateless firewall judges every packet on its own, so you must write rules for replies too. A stateful firewall remembers connections. If it allowed an outgoing request, it automatically allows the matching reply. Most modern firewalls and cloud security groups are stateful.
A VPN creates an encrypted tunnel between two points. Packets are encrypted, placed inside new packets, and sent over the public internet. At the other end they are decrypted and delivered. There are two main uses: remote access (a person's laptop joins the company network) and site-to-site (two offices or clouds are joined).
| Kind | Looks at | Good for | Limit |
|---|---|---|---|
| Packet filter (stateless) | Addresses, ports and protocol of each packet alone | Fast, simple rules | Does not know about connections, so replies need their own rules |
| Stateful firewall | The same, plus the state of the connection | Most servers and cloud networks | Cannot read the content of web requests |
| Application firewall / WAF | HTTP requests: URLs, headers, bodies | Blocking web attacks | Needs tuning, and can block real users by mistake |
| Next-generation firewall | Applications, users and threats | Company edges | Costly and complex |
| Host firewall | Traffic to and from one machine | Defence in depth | Must be managed on every machine |
| Security group | Network ACL | |
|---|---|---|
| Applies to | A server or network interface | A whole subnet |
| State | Stateful: replies are allowed automatically | Stateless: allow the return traffic too |
| Rule types | Allow rules (everything else is denied) | Allow and deny rules, checked in number order |
| Typical use | Main per-server control | Extra guard rail at the subnet edge |
1 ALLOW any -> web servers TCP 443 2 ALLOW office network -> servers TCP 22 (SSH) 3 DENY any -> servers TCP 22 4 ALLOW app subnet -> database TCP 5432 5 DENY any -> database TCP 5432 - DEFAULT: DENY everything else
| Tunnel mode | What goes through the tunnel | Trade-off |
|---|---|---|
| Full tunnel | All traffic from the device | Everything is protected on the local network, but all of it passes through the VPN, and the VPN operator can see where you go |
| Split tunnel | Only traffic for the company network | Faster and lighter, but other traffic is not protected by the VPN |
A teaching model with five rules and seven packets. Real firewalls match on many more fields (destination, protocol, direction) and cloud security groups are usually allow-only and stateful. A VPN does not make you anonymous and does not protect you from a site you log in to.
| Term | Meaning in easy words |
|---|---|
| Firewall | A system that allows or blocks network traffic using rules |
| Rule | A line that says allow or deny for traffic matching a source, destination, port and protocol |
| Default deny | The final policy: anything not explicitly allowed is blocked |
| Stateless filter | A filter that judges each packet alone, with no memory of connections |
| Stateful firewall | A firewall that tracks connections and automatically allows replies |
| Security group | A cloud firewall attached to a server, usually stateful and allow-only |
| Network ACL | A subnet-level rule list, often stateless and checked in numbered order |
| WAF | Web Application Firewall: filters HTTP requests for web attacks |
| VPN | Virtual Private Network: an encrypted tunnel across an untrusted network |
| Split / full tunnel | Sending only some traffic, or all traffic, through the VPN |
| Bastion host | A hardened server used as the one controlled entry point to a private network |
| Choice | We gain | We lose |
|---|---|---|
| Default deny | Safe by default | You must add a rule for every real need |
| Default allow | Everything works at first | Unknown traffic gets in |
| Stateful rules | Short, easy rules | More memory and connection tracking |
| Stateless rules | Very fast and simple | You must write rules for replies and can make mistakes |
| Full-tunnel VPN | Everything is protected on the local network | More load, slower pages, VPN operator sees your traffic |
| Split-tunnel VPN | Fast, only company traffic is carried | The rest is not protected by the VPN |
| Zero trust style access | Each request is checked, not just the network edge | More identity and policy work |