What Is a Firewall?

Author: Published

In brief: A firewall controls connections to and from a device or network, allowing or blocking them according to defined rules. It helps limit unwanted access, but does not replace updates, antivirus software or caution against scams. At home, an active operating system firewall and a properly configured router are usually a sufficient starting point.

How does a firewall work?

Data travels across a network in packets, which are small portions of information. A firewall evaluates these packets and connections against rules. It may consider the sender’s or recipient’s IP address, the direction of traffic, the protocol type and the port — a number identifying the service with which communication is to take place.

For example, a website using HTTPS, an encrypted connection to a site, is usually accessible through port 443. A server firewall can allow public traffic to that port while blocking access to the database port. This lets users open the website without being able to connect directly to its database.

Many firewalls track the state of connections. They recognise that a website’s response is part of communication initiated by the browser, rather than a separate attempt to gain access from outside. This is why blocking unsolicited incoming connections need not interfere with normal web browsing.

Rules can also apply to outgoing traffic, for example by preventing a particular application from connecting to the internet. However, not every firewall applies restrictive controls to these connections by default.

Where firewalls operate: computers, routers and the cloud

A firewall can protect a single device or control traffic between entire networks. These solutions complement one another because they operate in different places:

Firewall typeWhat it controlsTypical use
Operating system firewallConnections to and from a particular computer or serverProtecting a laptop even away from home
On a router or a separate deviceTraffic passing between networksSeparating a home or business network from the internet
Cloud firewallAccess to resources according to the service’s rulesRestricting access to servers and databases

A firewall does not therefore have to be a separate box. It can be an operating system feature, software on a router or a service offered by a cloud provider. You need to check the documentation for the particular solution to understand its scope and default settings.

A firewall should not be confused with NAT. NAT is an address translation mechanism that lets multiple devices share a public IPv4 address. In a typical home configuration, it makes unsolicited incoming connections more difficult, but it is not a substitute for a traffic filtering policy. With IPv6, where devices can have global addresses, correct firewall rules are also necessary.

What does a firewall protect against, and what will it not stop?

A firewall restricts access to services that should not be public and can block communication between separate parts of a network. For example, a business guest network might allow internet access but not connections to the accounting computer. A firewall enforces this separation only when the traffic actually passes through it.

Simply enabling a firewall does not protect against every threat, however. If a user enters a password on a fake website reached through an allowed HTTPS connection, a basic firewall will usually not prevent it. Nor will it fix vulnerabilities in a publicly accessible application or guarantee protection against an attack that overwhelms the internet connection.

Antivirus software and firewalls have different jobs. Antivirus software detects malicious files or behaviour on a device, while a firewall controls network communication. Security suites may combine both functions, but one does not replace the other.

A separate solution is a WAF, or web application firewall. It analyses requests sent to a website or API and can block certain attempts to exploit application flaws. It is not the same as a standard port-based firewall and does not remove the need to update the website’s software.

How can you configure a firewall safely at home?

On a personal computer, start by checking that the operating system firewall is active for all network profiles you use. The public profile is intended for untrusted networks, such as hotel Wi-Fi; it usually imposes stricter limits on device discovery and resource sharing.

If a program does not work because of the firewall, do not disable all protection. Follow this short procedure:

  1. Identify which function is not working and whether it actually requires incoming connections.
  2. Check the program’s official documentation for the required ports or access rules.
  3. Add the narrowest possible exception: for a specific application, network or source address.
  4. Test that it works and remove the exception when it is no longer needed.

For example, sharing files between a laptop and a home computer may require permission on a trusted private network. This does not mean the same service needs to be made available on hotel Wi-Fi or to the entire internet.

On the router, also check port forwarding: settings that direct connections from the internet to a device inside the network. Each forwarding rule should have a specific purpose; do not enable broad access just to solve a problem with one application.

What should you check before changing server rules?

On a server, a good starting point is to block incoming connections except to services you deliberately make available. Administrative access is best restricted to trusted addresses or a VPN, an encrypted tunnel to a private network.

Before tightening the rules, make sure you have emergency access through the provider’s console. An incorrect rule can lock out the administrator too. If protection is provided by both an operating system firewall and cloud rules, check both layers.

The first practical step is to review existing exceptions: establish who needs each allowed service, where they should be able to access it from and whether the permission is still needed.

See also: What Is 2FA?

Read also

Learn how PHP-FPM handles PHP requests, how it differs from a web server, and how to tune processes for traffic and hosting resources.
Learn how BIND, open-source DNS server software, handles domains, how its two roles differ and when running it yourself makes sense.
Learn what Poland’s REGON register and identification number mean, how they differ from NIP and KRS, and how to check a business’s details.