A small, menu-driven Python firewall simulator that lets you define allow/deny rules and test sample packets against them. The script logs each rule change and packet decision to firewall.log.
- Add and delete firewall rules interactively.
- Evaluate packets from a JSON file against the configured rules.
- Log rule changes and packet decisions for auditing.
- Python 3.8+ (standard library only)
- Clone the repository.
- Run the simulator:
python firewall.py
When you run the script, you will see an interactive menu:
- Add Rule
- Delete Rule
- Show Rules
- Process Packets
- Exit
Provide the action (allow or deny), source/destination IPs (or * for wildcard), protocol (TCP or UDP), and destination port (number or *). The rule is appended to the in-memory rules list.
Enter the numeric index shown in Show Rules to remove a rule.
packets.json contains example packets. Option 4 processes them through the rules and prints whether each packet is allowed or denied. The same results are logged in firewall.log.
firewall.py- Main simulation script.packets.json- Sample packet data for processing.firewall.log- Log output generated by the simulator.
- Rules are stored in memory for the current session only. Restarting the script resets the rules to the defaults defined in
firewall.py.
This project is licensed under the MIT License. See LICENSE.