Skip to content

Firewalls in Cybersecurity 🔥🛡️

A firewall is a security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules. It acts as a barrier between trusted and untrusted networks, helping to prevent unauthorized access, cyberattacks, and data breaches. Pasted image 20250317111416.png


Types of Firewalls and Their Functions

Firewall Type Description Example
1. Packet Filtering Firewall Operates at Layer 3 (Network) and Layer 4 (Transport) of the OSI model. It filters traffic based on IP address, port numbers, and protocol types. A router ACL (Access Control List) that allows only HTTP (port 80) and HTTPS (port 443) traffic while blocking other ports.
2. Stateful Inspection Firewall Keeps track of active connections and only allows incoming packets that are part of an established connection. More secure than packet filtering firewalls. Only allows inbound responses if they match an outbound request from a user inside the network.
3. Application Layer Firewall (Proxy Firewall) Operates at Layer 7 (Application Layer) and inspects actual data inside the packets (e.g., HTTP requests). Can block specific content or filter malicious traffic. A web proxy that blocks malicious HTTP requests containing SQL injection or XSS attack patterns.
4. Next-Generation Firewall (NGFW) Combines stateful inspection, deep packet inspection (DPI), intrusion detection/prevention (IDS/IPS), and application control. Can inspect encrypted traffic. A modern firewall that can block malicious IPs, detect malware, and enforce app-based policies (e.g., Palo Alto, Fortinet).

How Firewalls Are Positioned in a Network 🌍📡

1. Home Network Firewall Setup

  • A router/modem has a built-in firewall that filters traffic from the Internet.
  • It prevents unauthorized access while allowing safe web browsing.

🔗 Network Flow:
InternetRouter/Modem (Firewall)Devices (Laptop, PC, Phone, IoT Devices)

2. Enterprise Network Firewall Setup

  • A dedicated firewall appliance is placed between the Internet and internal corporate network.
  • All traffic must pass through the firewall before reaching internal servers.

🔗 Network Flow:
InternetFirewallRouter/SwitchInternal Network (PCs, Servers, Databases)


Firewall Deployment Models 🏢💻

Deployment Type Description Example
Host-Based Firewall Installed on an individual device (PC, server, laptop). Filters traffic specific to that machine. Windows Defender Firewall, iptables.
Network Firewall A hardware or virtual appliance securing an entire network from threats. Cisco ASA, FortiGate, pfSense.
Cloud Firewall A cloud-based security solution filtering traffic to/from cloud services. AWS WAF, Cloudflare Firewall.

Example: Basic Firewall Rules (Linux iptables)

# Allow SSH traffic from a specific IP
iptables -A INPUT -p tcp --dport 22 -s 192.168.1.100 -j ACCEPT

# Block all other SSH connections
iptables -A INPUT -p tcp --dport 22 -j DROP

# Allow web traffic (HTTP/HTTPS)
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Conclusion 🎯

Firewalls protect networks and devices by filtering malicious traffic. From basic packet filtering to advanced AI-driven next-gen firewalls, they are essential for cybersecurity in homes, businesses, and cloud environments.


Intrusion Detection and Prevention Systems (IDS/IPS) 🛡️🚨

IDS/IPS are security mechanisms designed to detect and respond to suspicious activities in a network or system.

  • Intrusion Detection System (IDS): Monitors and detects threats but does not block malicious traffic.
  • Intrusion Prevention System (IPS): Detects threats and actively blocks malicious traffic.

🔑 Key Difference → IDS = Detects & Alerts | IPS = Detects & Prevents


How IDS/IPS Works 🧐🔍

IDS/IPS analyze network packets using two primary techniques:

Detection Method Description Example
Signature-Based Detection Compares traffic to a database of known attack patterns (like an antivirus). Detecting SQL Injection attacks based on predefined rules.
Anomaly-Based Detection Identifies deviations from normal traffic patterns. Useful for detecting zero-day attacks. Detecting abnormal login attempts outside business hours.

Example IDS/IPS Solution: Suricata

Suricata is an open-source IDS/IPS that can analyze network traffic and block malicious packets in real time. It can be used in IDS mode (monitor only) or IPS mode (inline blocking).


Types of IDS/IPS

Type Description Example
1. Network-Based IDS/IPS (NIDS/NIPS) Monitors traffic at key network points (e.g., firewalls, core switches). A sensor connected to a switch monitoring traffic inside a data center.
2. Host-Based IDS/IPS (HIDS/HIPS) Runs on individual machines, analyzing logs, processes, and network traffic at the host level. An endpoint security agent installed on a Linux server.

Where to Place IDS/IPS in a Network? 🌐

IDS/IPS can be positioned strategically to monitor threats effectively:

🔗 Common Deployments:
1️⃣ Behind the Firewall – The firewall blocks obvious threats, and the IDS/IPS analyzes deeper traffic for attacks.
2️⃣ In the DMZ (Demilitarized Zone) – Protects public-facing servers from external threats.
3️⃣ On Endpoints – Runs directly on servers or workstations to monitor host-level attacks.

📌 Network Diagram:
🌍 InternetFirewallIPS/IDSRouterDevices (PCs, Servers, Smartphones) Pasted image 20250317112003.png


Best Practices for Securing Networks 🏆🔒

Practice Description
Define Clear Policies Set firewall & IDS/IPS rules using least privilege principles (only allow necessary traffic).
Regular Updates Keep firewalls, IDS/IPS, OS, and security signatures up to date.
Monitor & Log Events Regularly analyze logs and alerts to detect early signs of attacks.
Layered Security Approach Use firewalls + IDS/IPS + antivirus + endpoint security for multiple protection layers.
Periodic Penetration Testing Test the network's defenses with simulated attacks to identify weaknesses.

Conclusion 🎯

IDS/IPS are essential components of network security, working alongside firewalls to detect, block, and prevent cyberattacks. Whether it's NIDS/NIPS for network-wide monitoring or HIDS/HIPS for endpoint security, these systems enhance threat detection and response in modern cybersecurity environments.