</>
ShikshaCSLearn. Code. Grow.
🔍
☕ Support Us
ShikshaCSNotesComputer Networks
Computer Networks
🕒 9 min read

Firewalls and VPNs

The two most common tools for controlling and protecting network traffic.

What is a Firewall?

A firewall is a security system (hardware or software) that monitors and controls incoming and outgoing network traffic based on a set of defined rules — think of it as a security guard checking every packet trying to enter or leave a network, deciding whether to allow or block it based on criteria like source IP, destination port, or protocol type.

Types of Firewalls

Packet-filtering firewalls examine individual packets' headers (IP, port) against simple rules — fast but basic. Stateful firewalls track the STATE of active connections, understanding that a response packet belongs to a connection you initiated, making smarter allow/deny decisions. Application-layer (proxy) firewalls inspect the actual CONTENT of traffic (like checking if HTTP traffic is genuinely well-formed web traffic), offering the deepest but slowest inspection.

How Firewall Rules Work

Firewall rules typically specify: source address, destination address, port number, and protocol, paired with an action (ALLOW or DENY). Rules are usually processed in order, top to bottom, with the first matching rule applied — a classic setup is 'allow known-good traffic explicitly, then deny everything else by default' (a 'default deny' security posture).

What is a VPN?

A VPN (Virtual Private Network) creates an encrypted 'tunnel' between your device and a VPN server, routing your internet traffic through that secure tunnel. This hides your actual traffic content and original IP address from anyone observing the network you're directly connected to (like a public Wi-Fi network), and makes it appear as though your traffic originates from the VPN server's location instead.

Firewall vs VPN — Different Jobs

A firewall controls WHICH traffic is allowed to enter/leave a network in the first place. A VPN protects the PRIVACY and INTEGRITY of traffic that's already been allowed to travel, by encrypting it. They solve different problems and are commonly used TOGETHER — a company might use a firewall to control access to its internal network, while employees use a VPN to securely connect to that network from home.

🌍 Real-World Use

When you connect to public airport or café Wi-Fi and turn on a VPN, your data becomes encrypted before it even leaves your device, protecting you from anyone else on that same public network trying to intercept your traffic. Meanwhile, your home router's built-in firewall is quietly blocking unsolicited incoming connection attempts from the internet, 24/7, without you noticing.

💡 Pro Tip

A common exam trap confuses firewalls and VPNs as doing the 'same thing' — remember firewalls are about ACCESS CONTROL (who/what can connect), while VPNs are about ENCRYPTION and PRIVACY (protecting the data itself) — very different mechanisms solving very different problems.

🧪 Quick Self-Test

Check what you just learned — no pressure, just practice.

1. What is the main function of a firewall?

2. What does a VPN primarily provide?

3. Which firewall type tracks the state of active connections for smarter decisions?

← Back to all Notes