Skip to content
BENIBIX Learn

Firewall

Infrastructure🔒 SecurityDefences

Also known as Network Firewall, Host Firewall, Firewall Rule

A filter that lets some network traffic through and blocks the rest.

Think of it like

It is like a guard at a gate with a list. Only people on the list may come in.

Example

Jack's web server only needs ports 22, 80 and 443 open. His firewall blocks every other port. So a database left on by mistake cannot be reached from outside.

Why it matters

Every open port is a door. A firewall keeps the doors you did not mean to open shut.

Definition

A firewall is a filter that decides which network traffic may pass. It follows a list of rules. A rule can allow or block traffic by where it comes from, which port it uses or which way it goes. Most firewalls block all traffic coming in unless a rule allows it. A firewall can be a box on the network or a program on one computer.

Example code

bash
sudo ufw default deny incoming
sudo ufw allow 22/tcp
sudo ufw allow 443/tcp
sudo ufw enable
On Ubuntu, UFW sets up a firewall. Block all incoming traffic, then allow only SSH and HTTPS.
The firewall sits at the edge. Web traffic passes, and the rest is turned away.

Common mistake

Turning the firewall on over a remote link before allowing SSH. It locks you out of your own server.

Key takeaways

  1. 1
    Rules decide. Allow or block by address, port and direction.
  2. 2
    Deny by default. Block all, then open what is needed.
  3. 3
    One layer. It does not stop attacks on open ports.

Compare

Learn it properly