Wesloo
All topicsTopics

Computer security

How does a firewall work? Network security basics

Short answer

A firewall monitors and controls incoming and outgoing traffic using configurable rules. It commonly relies on packet filtering, proxying, and connection-state tracking to block unauthorized access. Hardware, software, and virtual forms can protect a single device or an entire network.

Key points

  • A firewall inspects packets and applies security rules to allow or block traffic.
  • Packet filtering, proxy service, and stateful inspection are its three main methods.
  • Rules can target ports, protocols, addresses, and user identities.
  • Hardware, software, and virtual firewalls fit different network sizes.
  • Firewalls are one layer and work best with other security controls.

How does a firewall work in practice?

How does a firewall work? It acts as a gatekeeper between a trusted network and an untrusted one, such as the internet, by inspecting traffic and applying security rules. The system can be a hardware device or a software program, and it watches data moving in both directions. By comparing packets with predefined rules, it blocks unauthorized access and suspicious activity.

A firewall is not one technique. It combines packet filtering, proxying, and connection-state tracking to control what enters and leaves a network. Some products also inspect outbound traffic, which can stop a compromised host from spreading malicious code.

What is a firewall?

As a network security system, a firewall watches traffic entering and leaving a network and applies configured rules. It often sits between a trusted network and an untrusted one, or between VLANs inside an organization. The aim is to allow legitimate communication while stopping unwanted or harmful traffic.

Firewalls can be hardware appliances, software programs, or virtual instances. A hardware unit often protects many devices at the network edge, while software can protect one computer or server. Both forms inspect packets and enforce policy, but they differ in placement and scale.

How does packet filtering work?

Packet filtering examines individual data packets and decides whether to pass or drop them. The decision uses fields such as source address, destination address, protocol, and port number. A rule might allow outgoing web requests while blocking incoming file transfer requests.

This method is fast because it checks each packet on its own. It does not remember whether a packet belongs to an established conversation. That limitation is why many firewalls add stateful inspection.

What does a proxy service do?

A proxy service acts as an intermediary between two networks for a specific application. Instead of allowing a direct connection from outside, the proxy receives the request, checks it, and then makes its own connection on behalf of the user. This extra step can add security and can support content caching.

Proxy firewalls are an early firewall type. They can prevent direct connections from outside the network and can inspect application-level details. The tradeoff is added processing and possible latency, because every request passes through an intermediary.

How does stateful inspection differ?

Stateful inspection tracks the state of active connections. It remembers that an outbound request was made and allows the matching response to return, while blocking unsolicited inbound traffic. This gives more context than packet filtering alone.

Because it understands connection state, stateful inspection can reduce false blocks and improve protection against certain attacks. It still relies on rules, but those rules are applied with awareness of whether a packet is part of an expected exchange.

How does a firewall inspect a connection step by step?

  1. It receives a packet at an interface.
  2. It checks the packet against ordered rules.
  3. It tracks whether the packet belongs to an active session.
  4. It allows, drops, or rejects the packet.
  5. It records the decision for review.

This sequence shows why rule order matters. A broad allow rule placed before a specific deny rule can let unwanted traffic through. Administrators therefore place precise rules first and test changes in a controlled way.

Which rules control access to services?

A service is usually tied to a port and protocol. Web traffic often uses ports 80 and 443, file transfer uses port 21, and email uses port 25. Firewalls use rules to decide which services are reachable, by whom, and in what context.

For instance, a firewall may stop inbound file transfers while permitting outbound secure web sessions. Rules can also use user identity, not just source or destination addresses. Identity-based rules can grant access by person, not just by address.

ServicePortTypical firewall decision
HTTP web traffic80Often allowed outbound
HTTPS web traffic443Often allowed outbound
FTP file transfer21Often restricted inbound
SMTP email25Controlled by mail policy

What should a basic rule set include?

A sensible starting set usually allows established outbound sessions and blocks unsolicited inbound traffic, while permitting only required services such as secure web access or mail. It should also log denied attempts so administrators can spot patterns. Rules should be reviewed when applications or network layouts change.

Identity-based rules can refine this set. For example, a finance application may be reachable only by specific users, even if they connect from different devices or locations. This reduces exposure without blocking normal work.

Hardware or software firewall?

A hardware firewall is a dedicated appliance placed between networks. It can protect many devices at once and is common at the edge of a business network. A software firewall runs on a host and protects that system, often with user-friendly controls.

Hardware units can handle high traffic and central policy, while software firewalls are easier to deploy on laptops and remote machines. Many organizations use both: an appliance at the perimeter and host-based protection on endpoints. The right choice depends on network size, budget, and management needs.

What is Zero Trust in firewall design?

Current designs may deploy virtual firewalls that fit Zero Trust strategies. These can apply the same policy in cloud and on-premises environments. Instead of trusting everything inside a perimeter, access is checked more continuously.

Zero Trust does not remove the need for rules. It changes the assumption that internal traffic is automatically safe. A firewall still inspects packets and applies policy, but the policy may follow users and workloads across locations.

How did commercial firewalls develop?

The PIX Firewall, launched in 1994 by Network Translation Inc., was an early product combining firewall and address translation features. It helped organizations link private networks to the public internet with few registered IP addresses. Cisco bought Network Translation Inc. in 1995; the PIX line was later replaced by the Adaptive Security Appliance platform in 2005.

This history shows why address translation and security became linked. As private networks grew, tools that controlled access and conserved addresses became essential. Modern firewalls still perform access control, but with broader features and deployment options.

How do firewalls fit with other security measures?

A firewall is one layer of defense. It filters traffic and enforces rules, but it does not replace secure passwords and patching. For example, a firewall may block an attack path, yet a phishing email can still trick a user into giving away credentials. Learning how to recognize phishing emails helps close that gap.

Firewalls also work alongside cryptography. Encryption protects data in transit, while a firewall controls which connections are allowed. Understanding how public-key cryptography works clarifies why both controls matter. A password manager application adds another layer by reducing reused or weak credentials.

What are common firewall limitations?

Firewalls depend on correct rules. A misconfigured rule can block legitimate traffic or allow unwanted traffic. They also cannot inspect traffic that is encrypted end to end unless additional decryption is configured, and they do not stop every threat that arrives through allowed channels.

Because of these limits, administrators review logs, update rules, and combine firewalls with other controls. The value of a firewall comes from consistent policy enforcement, not from a single setting.

Questions people also ask

What is the main job of a firewall?

Its main job is to inspect network traffic and apply rules that allow or block packets, protecting a trusted network from unwanted access.

What are the three main firewall methods?

Packet filtering, proxy service, and stateful inspection are the three main methods described for controlling traffic.

Can a firewall be software only?

Yes. A firewall can be a software program on a host, a hardware appliance, or a virtual instance.

Why do firewalls use port numbers?

Port numbers identify services such as web or email traffic, so rules can allow or restrict specific functions.

Does a firewall stop every cyber threat?

No. It reduces risk by filtering traffic, but it works best alongside passwords, patching, encryption, and user awareness.

Related pages

  • How do you create a strong password?

    A strong password is long, random, and used only once. A password manager can generate and store such passwords, while a memorable master password or passphrase protects the manager itself.

  • What is TLS traffic and how it protects web traffic

    TLS traffic is ordinary web traffic protected by the Transport Layer Security protocol. TLS encrypts the payload, verifies the server's identity with a certificate, and adds a message integrity check. The result is that eavesdroppers cannot read the data and tampering is detected.

  • What is ransomware attack? Definition and risks

    Ransomware is malware that blocks access to files, systems, or networks and demands payment for their return. Attackers often encrypt data. Backups, patching, and careful handling of email and remote access reduce the chance of a costly incident.

  • What is zero trust security model? A practical guide

    A zero trust security model is a framework that checks every access request instead of trusting users or devices by location. It uses identity, device health, and context to grant limited, temporary access. The goal is to reduce breach impact across cloud, remote, and on-premises systems.

  • What is a digital signature in Adobe Acrobat?

    A digital signature in Adobe is a certificate-based electronic signature used to sign and verify PDF documents. It confirms who signed, shows whether the file changed after signing, and supports compliance with strict regulations. Signers need a digital ID from a cloud provider or a local system before applying it.

  • How to Recognize Phishing Emails: Red Flags and Checks

    Phishing emails imitate trusted senders to steal passwords, account numbers, or other sensitive data. You can recognize them by checking the real sender domain, link destinations, wording, and the type of request. When a message feels off, verify it through a trusted channel and report it.

How this page was prepared

Before writing, the topic was researched in the sources below. The page then passed automatic quality checks.

Report a mistake on this page