What Is a Firewall? A Beginner’s Guide

The security guard at your network’s gate: what it checks, how it decides, and what it can’t protect you from.

Every network connected to the internet receives unwanted traffic all day: scans, login attempts and attacks. A firewall decides which traffic is allowed in, which is allowed out, and which is dropped.

Analogy: a firewall is the security guard at a building gate. The guard has a list of rules: staff may enter, delivery people may only go to the loading area, strangers are turned away. The guard checks every visitor against the list from top to bottom and acts on the first rule that matches.

What a firewall looks at

  • Source and destination IP address: where traffic comes from and where it's going
  • Protocol: TCP, UDP or ICMP (ping)
  • Port: which service, for example 443 for HTTPS or 22 for SSH
  • Interface: which side it arrived on, such as the internet (WAN) or the office (LAN)
  • Connection state: whether it's a new connection or a reply to one already allowed

Stateful firewalls remember conversations

Modern firewalls are stateful. When a computer inside opens a website, the firewall remembers that conversation. The website's reply is recognised as part of it ("established") and allowed back in. A brand-new connection from outside, which nobody inside asked for, can then be blocked. That's why most firewall configurations start with a rule that accepts established and related traffic.

Default allow vs default deny

  • Default allow: allow everything, then block known bad things. Easy, but anything you forget stays open.
  • Default deny: block everything, then allow only what is needed. Safer, and the approach security professionals recommend.

Types of firewall

TypeWhat it protectsExamples
Network firewallA whole network, at its edgeMikroTik, FortiGate, pfSense
Host firewallOne computer or serverWindows Defender Firewall, Linux ufw or firewalld
Cloud firewallCloud serversAWS Security Groups, Google Cloud firewall rules
Web application firewall (WAF)Websites, against attacks like SQL injectionCloudflare WAF, AWS WAF

A simple example on MikroTik

MikroTik groups rules into chains: input is traffic to the router itself, forward is traffic passing through the router, and output is traffic the router sends. These rules protect the devices behind the router:

/ip firewall filter
add chain=forward connection-state=established,related action=accept
add chain=forward connection-state=invalid action=drop
add chain=forward in-interface=ether1 connection-nat-state=!dstnat action=drop

In plain English: let replies through, drop broken packets, and drop any new connection from the internet unless you deliberately port-forwarded it. For protecting the router itself, see Step 9 of MikroTik basic setup.

What a firewall can't do

  • It can't stop a user from clicking a phishing link and typing their password.
  • It can't fix weak passwords or unpatched software.
  • It can't see inside encrypted traffic unless it's specially configured to.

A firewall is one layer of security. It works best alongside updates, strong passwords, multi-factor authentication and user awareness training.