What Is a Firewall? How Firewalls Work, Types, Security Rules, Ports, Configuration, and Best Practices
A firewall is a security system that monitors and controls network traffic entering or leaving a computer, server, network, or cloud environment according to...
A firewall is a security system that monitors and controls network traffic entering or leaving a computer, server, network, or cloud environment according to predefined security rules.
In simple terms, a firewall acts like a security checkpoint between a trusted network and another network that may not be trusted, such as the Internet.
Whenever computers communicate over a network, information is transmitted as packets. A firewall examines relevant information about this traffic and determines whether the communication should be:
- Allowed
- Blocked
- Rejected
- Logged
- Inspected further
For example, an organization may configure its firewall to allow normal HTTPS web traffic while preventing unsolicited Internet connections to internal computers.
Firewalls are one of the fundamental components of modern cybersecurity, but they should not be considered a complete security solution by themselves.
Why Is a Firewall Important?
Any computer connected to a network may potentially receive connection attempts from other devices.
Without appropriate security controls, unnecessary or vulnerable services could become reachable by unauthorized users or malicious software.
A properly configured firewall can help protect against:
- Unauthorized network access
- Unwanted inbound connections
- Access to unnecessary services
- Exposure of sensitive network ports
- Certain malware communication
- Network reconnaissance
- Some automated attacks
- Unauthorized outbound connections
- Access between restricted network segments
Firewalls are therefore commonly deployed on desktops, laptops, servers, routers, cloud networks, and corporate gateways.
How Does a Firewall Work?
A firewall sits logically between two systems or networks and evaluates network traffic against a set of rules.
A simplified communication path may look like:
Internet → Firewall → Internal Network → Computer/Server
For outgoing communication:
Computer/Server → Firewall → Internet
Suppose an Internet system attempts to connect to a company's server.
The firewall can evaluate information such as:
- Source IP address
- Destination IP address
- Source port
- Destination port
- Network protocol
- Connection state
- Network interface
- Application or service
- User or device identity on supported systems
- Packet characteristics
- Application-layer information on advanced firewalls
The firewall then applies its configured policy.
For example:
Allow TCP traffic to destination port 443
would normally permit HTTPS traffic matching that rule.
Another rule might specify:
Block inbound TCP traffic to port 3389 from the Internet
This could be used to prevent direct Internet access to Microsoft's Remote Desktop Protocol service.
Understanding Firewall Rules
Firewall behavior is primarily controlled using rules.
A rule normally defines:
Source → Destination → Protocol → Port/Service → Action
Example:
192.168.1.0/24 → Server → TCP → 443 → Allow
This could allow computers on the specified internal subnet to access an HTTPS service running on the server.
A firewall rule may contain parameters such as:
- Source address
- Destination address
- Protocol
- Source port
- Destination port
- Application
- Interface
- Direction
- User
- Schedule
- Action
- Logging settings
The exact options depend on the firewall product.
Inbound vs Outbound Firewall Traffic
Understanding traffic direction is important when configuring firewalls.
Inbound Traffic
Inbound traffic is network communication arriving at the protected system or network.
Examples include:
- A computer connecting to a web server
- An administrator connecting to a server using RDP
- A client accessing a file server
- An external system attempting to connect to a service
Inbound rules determine which incoming connections are permitted.
Outbound Traffic
Outbound traffic originates from the protected computer or network.
Examples include:
- Opening a website
- Sending email
- Downloading Windows updates
- Connecting to cloud services
- Software contacting a licensing server
Outbound filtering can be useful for controlling which applications or systems are allowed to communicate externally.
What Are Firewall Ports?
Network applications commonly communicate using TCP or UDP ports.
A port can be considered a logical communication endpoint associated with a particular service or application.
Some commonly encountered ports include:
| Port | Protocol/Service | Common Purpose |
|---|---|---|
| 20/21 | FTP | File Transfer |
| 22 | SSH | Secure remote administration |
| 25 | SMTP | Email transfer |
| 53 | DNS | Domain name resolution |
| 80 | HTTP | Web traffic |
| 110 | POP3 | Email retrieval |
| 143 | IMAP | Email retrieval |
| 443 | HTTPS | Encrypted web traffic |
| 445 | SMB | Windows file/printer sharing |
| 993 | IMAPS | Secure IMAP |
| 995 | POP3S | Secure POP3 |
| 3389 | RDP | Windows Remote Desktop |
A firewall can allow or deny connections based on these ports.
However, port numbers alone should not always be treated as proof of the application using the connection. Advanced security systems can inspect application-layer traffic for better identification.
What Is an Open Port?
An open port generally means that a network service is listening on that port and can potentially accept connections, assuming network routing and firewall rules permit access.
An open port is not automatically dangerous.
For example, a public web server normally needs TCP port 443 available to users.
The security concern arises when unnecessary, vulnerable, or poorly protected services are exposed.
Therefore, organizations should follow a simple principle:
Only expose network services that are genuinely required.
Types of Firewalls
Different firewall technologies operate at different levels and provide different capabilities.
1. Packet-Filtering Firewall
Packet-filtering firewalls inspect packet information such as:
- Source IP
- Destination IP
- Protocol
- Source port
- Destination port
Rules determine whether packets should be permitted or denied.
Packet filtering is relatively simple and efficient but provides less context than more advanced firewall technologies.
2. Stateless Firewall
A stateless firewall evaluates individual packets without maintaining detailed information about the overall connection.
Each packet is evaluated independently.
This can provide fast filtering but generally offers less context than stateful inspection.
3. Stateful Firewall
A stateful firewall maintains information about active network connections.
For example, when an internal computer establishes a legitimate connection to a website, the firewall remembers the connection state and can recognize response traffic associated with that session.
Stateful inspection is widely used in modern network firewalls.
4. Proxy Firewall
A proxy firewall can act as an intermediary between clients and destination services.
Instead of a client communicating directly with the external destination, communication may occur through the proxy.
This architecture can provide additional control and inspection.
5. Application-Layer Firewall
Application-aware firewalls can analyze traffic beyond basic IP addresses and ports.
They may identify or control protocols and applications such as:
- HTTP
- HTTPS
- DNS
- FTP
- Email protocols
- Business applications
Modern enterprise firewalls increasingly use application awareness to implement more granular security policies.
6. Next-Generation Firewall (NGFW)
A Next-Generation Firewall, commonly abbreviated NGFW, combines traditional firewall functionality with additional security capabilities.
Depending on the product, these may include:
- Application identification
- Deep packet inspection
- Intrusion prevention
- Malware detection
- URL filtering
- User-based policies
- SSL/TLS inspection
- Threat intelligence
- VPN functionality
NGFW products are commonly used in business and enterprise environments.
7. Web Application Firewall (WAF)
A Web Application Firewall protects web applications and HTTP/HTTPS services.
Unlike a traditional network firewall, a WAF focuses heavily on web application traffic.
It can help detect or block certain application-layer attacks such as:
- SQL injection
- Cross-site scripting
- Malicious HTTP requests
- Certain automated attacks
- Suspicious request patterns
A WAF does not normally replace a network firewall. They protect different layers of infrastructure.
8. Host-Based Firewall
A host-based firewall runs directly on an individual endpoint.
Examples include firewalls installed on:
- Windows computers
- Linux servers
- Laptops
- Workstations
- Application servers
Microsoft Windows includes a built-in host firewall.
Host firewalls are particularly useful because they can protect a computer even when it is connected to networks outside the organization's main perimeter.
9. Network Firewall
A network firewall protects multiple devices by controlling traffic passing between networks.
For example:
Internet → Network Firewall → Office LAN
Network firewalls are frequently deployed at Internet gateways, between VLANs, and between internal security zones.
10. Cloud Firewall
Cloud firewalls provide traffic filtering for cloud-hosted infrastructure.
Depending on the cloud platform and architecture, firewall functionality may be implemented using:
- Security groups
- Network ACLs
- Virtual firewalls
- Cloud-native firewall services
- Web application firewalls
Cloud firewall rules should follow the same principle of exposing only required services.
Hardware Firewall vs Software Firewall
Hardware Firewall
A hardware firewall is usually a dedicated physical or virtual network appliance positioned between networks.
It can protect multiple systems simultaneously.
Common deployments include:
Internet → Firewall Appliance → Switch → Office Computers
Hardware firewall platforms are commonly used by businesses.
Software Firewall
A software firewall operates on an individual computer or server.
For example:
Windows Computer → Microsoft Defender Firewall
Software firewalls provide device-level protection and can apply rules based on applications, services, ports, addresses, and network profiles.
Should You Use Both?
In many business environments, yes.
A layered design could be:
Internet → Network Firewall → Internal Network → Endpoint Firewall → Application
This provides protection at multiple points instead of relying on one security control.
Windows Firewall
Modern versions of Windows include Microsoft Defender Firewall.
It provides filtering for different Windows network profiles:
- Domain
- Private
- Public
Administrators can create inbound and outbound rules based on applications, services, ports, protocols, and addresses.
Advanced management is available through:
Windows Defender Firewall with Advanced Security
Administrators can also manage firewall settings using technologies such as:
- Group Policy
- PowerShell
- Microsoft management platforms
- Security management solutions
Windows Firewall Network Profiles
Windows classifies network connections using profiles.
Domain Profile
Normally used when a Windows computer is connected to and authenticated with its organization's Active Directory domain network.
Private Profile
Used for trusted private networks such as an appropriately configured home or internal network.
Public Profile
Designed for untrusted networks such as public Wi-Fi.
The Public profile should generally apply more restrictive rules because other devices on the network should not automatically be trusted.
Firewall and Remote Desktop Protocol (RDP)
RDP commonly uses TCP/UDP port 3389 by default.
Allowing unrestricted RDP directly from the Internet can create significant security exposure.
A safer design may use:
- VPN
- Remote Desktop Gateway
- Zero Trust access technologies
- Restricted source IP addresses
- Multi-factor authentication
- Strong authentication controls
- Account lockout policies
- Network Level Authentication
Where possible, direct public exposure of administrative services should be avoided.
Firewall and NAT
Network Address Translation (NAT) and firewalling are related but are not the same thing.
NAT translates IP addresses between networks.
For example, multiple internal computers using private addresses such as:
192.168.1.x
may share a public Internet IP address through a router.
A firewall, meanwhile, decides which traffic should be allowed or denied.
Many routers perform both NAT and firewall functions, which sometimes causes users to confuse the two technologies.
Firewall vs Router
A router's primary role is to route traffic between networks.
A firewall's primary role is to enforce network security policies.
Modern business routers and security appliances may provide both routing and firewall capabilities.
Therefore, one physical device may function as:
Router + Firewall + VPN Gateway + NAT Device
Firewall vs Antivirus
A firewall and antivirus software perform different security functions.
| Firewall | Antivirus |
|---|---|
| Controls network communication | Detects malicious software/files |
| Filters connections | Scans files/processes |
| Can block network access | Can quarantine malware |
| Controls ports/protocols | Detects malicious code |
| Helps reduce network exposure | Helps detect endpoint threats |
One does not replace the other.
A well-protected endpoint commonly uses both firewall and endpoint security technologies.
Firewall vs VPN
A firewall controls which network communications are permitted.
A VPN creates an encrypted communication tunnel between endpoints or networks.
For example, a company may configure:
Remote Employee → Encrypted VPN → Corporate Firewall → Internal Server
The VPN provides secure connectivity while the firewall determines what resources the connected user or device may access.
Firewall vs Proxy Server
A proxy acts as an intermediary for particular communications.
A firewall primarily applies security policies to network traffic.
Some advanced security products combine firewall and proxy capabilities, so the distinction can become less obvious in modern platforms.
Firewall vs Web Application Firewall
A traditional firewall generally protects network connectivity.
A WAF specifically focuses on web application traffic.
For example:
Internet → Network Firewall → WAF → Web Server
This layered design can protect both the network infrastructure and the web application.
What Is Deep Packet Inspection?
Basic packet filtering examines information such as IP addresses, protocols, and ports.
Deep Packet Inspection (DPI) can examine additional portions of network traffic to identify applications, protocols, or potentially malicious patterns.
DPI may be used for:
- Application identification
- Intrusion prevention
- Malware detection
- Policy enforcement
- Traffic classification
Encrypted traffic can limit visibility unless appropriate inspection mechanisms are deployed.
What Is a Firewall ACL?
An Access Control List (ACL) is a collection of rules specifying which traffic is allowed or denied.
Example:
Allow 192.168.10.0/24 → Server 192.168.20.10 → TCP 443
Deny Any → Server 192.168.20.10 → TCP 3389
ACLs are commonly used in:
- Firewalls
- Routers
- Switches
- Cloud networks
- Security appliances
What Is Default Deny?
One of the strongest firewall design principles is:
Deny by default and allow only what is required.
Instead of allowing everything and blocking known dangerous traffic, the administrator defines explicitly permitted communication.
Conceptually:
Default policy: DENY
Then specific rules are created:
Allow HTTPS
Allow required DNS
Allow approved VPN traffic
Allow administrative access only from management networks
This reduces unnecessary exposure.
Network Segmentation with Firewalls
Firewalls should not necessarily be used only between an organization and the Internet.
They can also separate internal networks.
For example:
Internet
↓
Firewall
↓
Corporate LAN
↓
Internal Firewall/Segmentation
↓
Server Network
Separate VLANs or security zones could be created for:
- Employees
- Servers
- Guests
- CCTV systems
- IoT devices
- VoIP systems
- Management interfaces
- Backup infrastructure
Firewall rules can then determine which networks are allowed to communicate.
This limits unnecessary lateral movement if one device becomes compromised.
What Is a DMZ?
A DMZ, or demilitarized zone, is a separate network segment commonly used for systems that must provide services to less-trusted networks.
For example:
Internet
↓
Firewall
↓
DMZ – Public Web Server
↓
Firewall Rules
↓
Internal Network
The goal is to prevent a publicly accessible server from having unrestricted access to the organization's internal network.
Firewall Logging
Logging is one of the most important but sometimes overlooked firewall capabilities.
Firewall logs can record information such as:
- Source IP
- Destination IP
- Port
- Protocol
- Connection time
- Allowed traffic
- Blocked traffic
- Security rule triggered
- User identity
- Application
- Threat detection
Logs can help administrators investigate connectivity problems and security incidents.
Common Firewall Problems
Firewall-related problems may include:
Application Cannot Connect
A required port or application may be blocked.
Remote Desktop Does Not Work
RDP rules, network profiles, NAT configuration, or upstream firewalls may prevent the connection.
File Sharing Stops Working
SMB traffic may be blocked between network segments.
Software Activation Fails
Some applications need outbound access to licensing servers.
Website or Cloud Service Is Unreachable
DNS, HTTPS, proxy, URL filtering, or application-control rules may be responsible.
Ping Does Not Work
ICMP may be blocked.
However, failure to receive a ping response does not necessarily mean the destination system is offline.
Should You Disable the Firewall for Troubleshooting?
Disabling the firewall completely is generally a poor long-term troubleshooting method.
A better approach is to determine:
- Which application is failing?
- Which destination is being contacted?
- Which protocol is being used?
- Which port is required?
- Which firewall rule is blocking the connection?
- Does the application require inbound or outbound access?
Then create the minimum necessary exception.
Temporary firewall disabling may sometimes be used by an administrator as a controlled diagnostic test, but protection should be restored immediately afterward.
Common Firewall Configuration Mistakes
Allowing Any Source to Administrative Ports
Rules such as:
ANY → TCP 3389 → ALLOW
can unnecessarily expose RDP.
Opening Large Port Ranges
Avoid permitting hundreds or thousands of ports when an application needs only a few.
Using "Allow Any" Rules
Overly broad rules weaken network segmentation.
Keeping Obsolete Rules
Rules created for old applications or servers should be reviewed and removed when no longer required.
Ignoring Outbound Traffic
Outbound controls can help restrict unwanted external communications.
Not Reviewing Logs
Security events may remain unnoticed if firewall logs are never monitored.
Exposing Management Interfaces
Firewall, router, hypervisor, NAS, and other administrative interfaces should not be publicly accessible unless specifically required and strongly protected.
Firewall Best Practices
Organizations should follow several firewall security practices:
- Keep the firewall enabled.
- Apply a default-deny approach where practical.
- Open only required ports.
- Restrict rules to necessary source and destination addresses.
- Avoid exposing administrative interfaces directly to the Internet.
- Use VPN or other secure remote-access technologies.
- Review firewall rules periodically.
- Remove obsolete rules.
- Enable appropriate logging.
- Monitor unusual blocked and allowed traffic.
- Keep firewall firmware/software updated.
- Back up firewall configurations.
- Document important rules.
- Separate guest and corporate networks.
- Segment sensitive servers.
- Protect firewall administration with strong authentication.
- Use MFA for administrative access where supported.
- Restrict management access to trusted networks.
- Combine firewalls with endpoint protection.
- Regularly test security controls.
Example Small-Business Firewall Architecture
A small business might use:
Internet
↓
ISP Modem/ONT
↓
Business Firewall/Router
↓
Managed Network Switch
↓
VLAN 10 – Employee Computers
VLAN 20 – Servers
VLAN 30 – Guest Wi-Fi
VLAN 40 – CCTV/IoT
Firewall rules can restrict communication between these networks.
For example:
Guest Wi-Fi could access the Internet but not internal servers.
CCTV devices could communicate only with the required recorder or management server.
Employee computers could access authorized business servers.
Server management interfaces could be accessible only from administrator computers.
This provides substantially better security than placing every device on one unrestricted network.
Can a Firewall Stop Hackers?
A firewall can significantly reduce network exposure, but it cannot guarantee that a system will never be compromised.
Attackers may exploit:
- Vulnerable applications
- Stolen passwords
- Phishing
- Malicious attachments
- Browser vulnerabilities
- Misconfigured cloud services
- Weak authentication
- Unpatched systems
- Trusted applications
- Social engineering
For this reason, cybersecurity requires multiple layers of protection.
A stronger security architecture may include:
Firewall + Endpoint Security + MFA + Updates + Backups + Email Security + Network Segmentation + Monitoring + User Awareness
This concept is commonly described as defense in depth.
Firewall and Zero Trust Security
Traditional network security often assumed that systems inside the corporate network were more trustworthy.
Modern Zero Trust strategies follow a different principle:
Never automatically trust a connection merely because it originates from an internal network.
Access decisions can consider:
- User identity
- Device identity
- Authentication status
- Device security posture
- Application
- Destination
- Risk level
- Network context
Firewalls remain important in Zero Trust architectures, particularly for segmentation and policy enforcement.
Is a Firewall Required for Home Users?
Yes, firewall protection remains useful for home computers.
Most home environments already have two important firewall layers:
Internet Router Firewall
and
Operating-System Firewall
Users should generally keep both enabled.
Modern Windows computers should normally keep Microsoft Defender Firewall active on all applicable network profiles.
Is a Firewall Required for Businesses?
Yes.
Businesses typically require stronger controls because they may operate:
- File servers
- Remote Desktop servers
- Accounting systems
- ERP software
- NAS devices
- Cloud infrastructure
- CCTV systems
- VPN services
- Web servers
- Database servers
- Business applications
Business networks should generally use both perimeter/network firewall protection and host-based firewall protection where appropriate.
Frequently Asked Questions (FAQ)
1. What is a firewall in simple words?
A firewall is a security system that controls network traffic and decides which connections should be allowed or blocked.
2. Why is a firewall needed?
A firewall helps prevent unauthorized network access and reduces unnecessary exposure of computers and services.
3. Does Windows have a firewall?
Yes. Modern Windows versions include Microsoft Defender Firewall.
4. Should Windows Firewall be enabled?
In normal circumstances, yes. It should generally remain enabled unless another properly managed security solution provides the required firewall functionality.
5. Is a firewall the same as antivirus?
No. A firewall controls network communications, while antivirus or endpoint security primarily detects and responds to malicious files, applications, and behavior.
6. Can I use a firewall and antivirus together?
Yes. They provide different layers of security and are commonly used together.
7. What is a hardware firewall?
A hardware firewall is a dedicated network appliance that filters traffic between networks and can protect multiple devices.
8. What is a software firewall?
A software firewall runs directly on an individual computer or server.
9. What is an inbound firewall rule?
An inbound rule controls traffic attempting to reach the protected computer or network.
10. What is an outbound firewall rule?
An outbound rule controls connections initiated by the protected computer or network.
11. What is an open firewall port?
It generally refers to a firewall configuration permitting traffic to a particular port. For a connection to succeed, a service must also normally be listening and reachable.
12. Is opening a port dangerous?
Not automatically. Risk depends on what service is exposed, who can access it, how securely it is configured, and whether the software is properly maintained.
13. What is port 443?
TCP port 443 is conventionally used for HTTPS web traffic.
14. What is port 80?
TCP port 80 is conventionally used for HTTP web traffic.
15. What is port 3389?
TCP/UDP port 3389 is commonly associated with Microsoft Remote Desktop Protocol.
16. Should port 3389 be open to the Internet?
Direct unrestricted exposure is generally discouraged. Secure remote-access architecture such as VPN, RD Gateway, restricted source addresses, MFA, and other controls should be considered.
17. What is a next-generation firewall?
An NGFW combines traditional firewall functions with capabilities such as application awareness, intrusion prevention, and advanced traffic inspection.
18. What is a WAF?
A Web Application Firewall protects web applications by inspecting HTTP/HTTPS traffic and applying application-layer security rules.
19. What is packet filtering?
Packet filtering examines network packet characteristics such as IP addresses, ports, and protocols to determine whether traffic should be allowed.
20. What is stateful inspection?
Stateful inspection tracks active network connections so the firewall can make decisions based on the state and context of a session.
21. What is firewall logging?
Firewall logging records information about network traffic and security-rule decisions for troubleshooting, auditing, and security analysis.
22. Can a firewall block malware?
A firewall may block certain malicious network communications, but it is not a replacement for endpoint security or antivirus protection.
23. Can a firewall stop ransomware?
A firewall can reduce certain attack paths and communications, but ransomware prevention requires multiple security controls.
24. Does a VPN replace a firewall?
No. VPNs provide secure encrypted connectivity, while firewalls control which communications are permitted.
25. Does a router have a firewall?
Many modern routers include firewall functionality, but capabilities vary significantly between consumer and business products.
26. What is a firewall policy?
A firewall policy is the collection of rules and security decisions defining which traffic is permitted or denied.
27. What does "deny by default" mean?
It means traffic is blocked unless an explicit rule permits it.
28. What is network segmentation?
Network segmentation divides a network into separate zones or VLANs and controls communication between them.
29. What is a DMZ?
A DMZ is a separate network zone commonly used for externally accessible systems so they can be isolated from sensitive internal networks.
30. Should small businesses use a firewall?
Yes. Small businesses can also be targets of ransomware, credential theft, automated scanning, and other cyberattacks, making firewall protection an important security layer.
Conclusion
A firewall is one of the foundational technologies of computer and network security. It controls network communication by applying security rules to incoming and outgoing traffic.
Modern firewall technologies range from the host-based firewall built into a Windows computer to enterprise next-generation firewalls protecting thousands of systems and cloud workloads.
However, simply installing a firewall does not guarantee security. Its effectiveness depends heavily on correct configuration.
A strong firewall strategy follows several fundamental principles:
Block unnecessary access.
Permit only required services.
Restrict sensitive services to trusted sources.
Segment networks where appropriate.
Monitor firewall activity.
Keep firewall software and firmware updated.
Most importantly, a firewall should form part of a layered cybersecurity strategy rather than being treated as the only security control.
#tags
#Firewall #WhatIsFirewall #FirewallSecurity #NetworkFirewall #NetworkSecurity #CyberSecurity #ComputerSecurity #InternetSecurity #WindowsFirewall #MicrosoftDefenderFirewall #HardwareFirewall #SoftwareFirewall #CloudFirewall #NextGenerationFirewall #NGFW #WebApplicationFirewall #WAF #PacketFiltering #StatefulFirewall #FirewallRules #FirewallConfiguration #FirewallPorts #OpenPorts #TCP #UDP #IPAddress #PortFiltering #NetworkProtection #EndpointSecurity #PerimeterSecurity #RouterFirewall #ServerSecurity #BusinessSecurity #EnterpriseSecurity #FirewallManagement #FirewallMonitoring #FirewallLogs #RDP #RemoteDesktop #VPN #NetworkSegmentation #VLAN #DMZ #ZeroTrust #AccessControl #CyberAttack #MalwareProtection #RansomwareProtection #ITSecurity #FirewallBestPractices
Was this guide useful?
Your answer helps us keep BISONKB accurate and practical.