This repository contains a Python script for generating firewall rules based on user inputs. The script supports both Windows and Linux platforms, allowing users to generate platform-specific firewall rules using netsh for Windows and iptables for Linux. With this tool, users can easily generate custom firewall rules by specifying the source IP, destination IP, port, and action (ACCEPT or DROP). This script simplifies the process of generating firewall rules and can be used in real-world scenarios to enhance network security.
- Generates firewall rules for Windows and Linux platforms
- Supports both
netshcommand for Windows andiptablescommand for Linux - User-friendly interface for specifying source IP, destination IP, port, and action (ACCEPT or DROP)
- Python 3.6 or higher
-
Clone or download this repository to your local machine.
-
Open a terminal or command prompt and navigate to the repository directory.
-
Run the script using the following command:
python firewall_rule_generator.py -
Follow the prompts to enter the required information:
- Source IP (in CIDR notation)
- Destination IP (in CIDR notation)
- Port
- Action (ACCEPT or DROP)
-
Once you provide the required inputs, the script will generate the corresponding firewall rule.
Enter the source IP (in CIDR notation): 192.168.0.10/32
Enter the destination IP (in CIDR notation): 0.0.0.0/0
Enter the port: 80
Enter the action (ACCEPT or DROP): ACCEPT
Generated Firewall Rule:
- Windows: netsh advfirewall firewall add rule name="Custom Rule" dir=in action=ACCEPT localport=80 protocol=TCP remoteip=192.168.0.10/32
- Linux: iptables -A INPUT -s 192.168.0.10/32 -d 0.0.0.0/0 -p tcp --dport 80 -j ACCEPT
Enter the source IP (in CIDR notation): 10.0.0.5/32
Enter the destination IP (in CIDR notation): 0.0.0.0/0
Enter the port: 0
Enter the action (ACCEPT or DROP): DROP
Generated Firewall Rule:
- Windows: netsh advfirewall firewall add rule name="Custom Rule" dir=in action=DROP remoteip=10.0.0.5/32
- Linux: iptables -A INPUT -s 10.0.0.5/32 -d 0.0.0.0/0 -j DROP
This project is licensed under the MIT License.
e-mail : ajithchandranr@protonmail.com
linkedin : https://www.linkedin.com/in/ajithchandranr/