Firewall Implementation Using Linear Rule Matching Algorithm

Mohammed Eunus AliInternational Journal for Research in Applied Science and Engineering Technology 2025 · DOI

TL;DR

This paper introduces Firewall Master, a lightweight, Python-based software firewall designed to replace the "black box" nature of commercial security appliances with a transparent, modular framework. By utilizing a linear rule-matching engine and an iterative logging-to-refinement loop, the system achieves high filtering accuracy and low latency, making it an ideal tool for cybersecurity education and resource-constrained IoT environments.

What Problem Does This Paper Address?

In the world of network security, firewalls are the first line of defense. However, most commercial solutions are proprietary hardware appliances that operate as "black boxes." For students, researchers, and developers, this lack of transparency makes it difficult to understand the underlying logic of packet filtering or to prototype custom security algorithms.

Furthermore, traditional enterprise firewalls often require specialized hardware and complex configurations that are overkill for small-scale research labs or lightweight IoT deployments. There is a clear research gap for a modifiable, software-defined firewall that is easy to deploy on standard hardware while remaining performant enough for real-time use.

Methods

The authors developed Firewall Master using Python, prioritizing modularity and ease of use. The system architecture is broken down into four primary components:

  • PacketSniffer Module: Uses the scapy library to capture and parse raw packets across the Ethernet, IP, TCP, and UDP layers.
  • RuleEngine Module: Implements a linear matching algorithm. It evaluates incoming packets against a sequential list of user-defined rules (stored in simple JSON or CSV formats) based on source/destination IPs, ports, and protocols.
  • Logger Module: A critical feature that records "unmatched" packets. This allows administrators to analyze traffic that didn't trigger existing rules and iteratively refine the security policy.
  • Admin Interface: Provides a CLI/GUI for real-time rule management without requiring kernel-level modifications.

The "Linear Rule Matching" aspect means the engine checks rules one by one until a match is found. While simpler than complex tree-based algorithms, this approach ensures high transparency and ease of debugging for its intended educational and small-scale use cases.

Datasets

The system was evaluated using a simulated network environment specifically designed for this study.

  • Traffic Composition: The environment generated a mix of "benign" (legitimate) and "malicious" traffic.
  • Benchmarking: While the paper does not cite a standard public dataset (like the KDD Cup), it uses this controlled environment to measure specific performance metrics like accuracy, latency, and resource consumption across different rule configurations (e.g., Basic Rule Set vs. Refined + Adaptive Logging).

Key Insights and Ideas

  • The "Semi-Adaptive" Loop: One of the most interesting ideas is using the logging of unmatched packets to create a manual feedback loop. By analyzing what the firewall didn't know how to handle, the authors showed that users could significantly improve filtering accuracy in subsequent runs.
  • Transparency as a Learning Tool: By moving firewall logic from the kernel/hardware level to a high-level language like Python, the authors demonstrate that network security can be made accessible to non-experts and students without sacrificing basic functionality.
  • Efficiency on Low-End Hardware: The results suggest that a well-optimized Python framework can handle real-time traffic with minimal overhead, proving that software-defined security is viable for the "edge" (like Raspberry Pi or IoT gateways).

Key Results

The experimental results validate the framework's efficiency:

  • Filtering Accuracy: The system achieved an average accuracy of 94.7% after rule refinement.
  • Latency: Processing delay averaged just 8.5 milliseconds per packet, which is sufficient for latency-sensitive applications like VoIP or gaming in low-traffic environments.
  • Resource Footprint: CPU utilization remained below 15% and memory usage stayed under 100MB, confirming its lightweight nature.
  • Iterative Improvement: After just one refinement cycle based on log analysis, unmatched traffic was reduced by 76%.
  • Usability: In testing, 80% of non-technical participants were able to successfully modify firewall rules after a brief demonstration.

Limitations and Future Work

The authors acknowledge several areas for growth:

  • Manual Refinement: Currently, the "adaptive" part of the system requires a human to review logs and update rules. The authors suggest integrating AI-based anomaly detection to automate this process in the future.
  • Scalability: While linear matching is transparent, it may face performance bottlenecks in high-bandwidth enterprise environments with thousands of rules.
  • Interface & Integration: Future work includes developing a more robust web-based GUI, creating REST APIs for remote rule updates, and implementing cloud-based dashboards for distributed network monitoring.

Summary updated

Abstract

Firewalls have long served as the foundational defense mechanism in network security, tracing their roots to early packet-filtering technologies designed to prevent unauthorized access. Traditional firewalls, however, often struggle with limited transparency, static rule sets, and high hardware dependency, making them less suited for dynamic and educational environments. As networks grow in scale and complexity, these constraints highlight the need for more adaptable and modular firewall systems. This paper presents Firewall Master, a Python-based software firewall framework designed with modularity, transparency, and user control at its core. The system performs real-time packet inspection using a customizable rule engine that filters traffic based on IP addresses, ports, and transport layer protocols. Unmatched packets are logged for future analysis, enabling adaptive rule refinement. The lightweight architecture ensures accessibility for students, researchers, and small network environments while laying the groundwork for future integrations with AI-based anomaly detection. Experimental results show that the system effectively filtered over 74% of network traffic on first execution and adapted to logbased rule refinements with over 80% improvement in subsequent runs. The firewall achieved low latency (<10ms per packet) and performed reliably on low-resource systems, validating its efficiency and educational value.
BibTeX
@article{ali2025firewall,
  author = {Mohammed Eunus Ali},
  title = {{Firewall Implementation Using Linear Rule Matching Algorithm}},
  journal = {International Journal for Research in Applied Science and Engineering Technology},
  year = {2025},
  doi = {10.22214/ijraset.2025.74057},
}
Figure