- Issues: Report an Issue
Managing firewall rules on Cisco Firepower Threat Defense (FTD) devices can be a time-consuming and error-prone task, especially in large-scale environments. This project provides a Python-based solution to automate the process of creating, updating, and deleting firewall rules using the Firepower Management Center (FMC) API.
This tool is designed to:
- Streamline firewall rule management.
- Reduce manual configuration errors.
- Enable bulk operations for large rule sets.
- Provide a flexible and scriptable interface for network administrators.
- Rule Creation: Automates the creation of access control rules.
- Rule Modification: Updates existing rules with new parameters (e.g., source/destination IPs, ports, actions).
- Rule Deletion: Removes rules from the configuration.
- Bulk Operations: Allows actions on multiple rules simultaneously.
- Logging and Reporting: Generates logs and reports for audit purposes.
- API Integration: Utilizes the Cisco FMC REST API for seamless integration.
Ensure you have the following before using this tool:
- Python 3.7 or higher (Required for script execution)
- Cisco FMC API Access (Ensure API access is enabled)
- API Credentials (Username, password, and API token for authentication)
- Required Python Libraries:
requests
json
logging
argparse
To install the required libraries, run:
pip install requests json logging argparse
-
Clone the repository:
git clone https://github.com/mrdc82/cisco_ftd_rule_automation.git cd cisco_ftd_rule_automation
-
Install dependencies:
pip install -r requirements.txt
-
Configure FMC API credentials: Update the generate_token.py file with your FMC token details:
-
Configure URL details: Update the generate_token.py and PUT_acp_new_rules.py file with your FMC ip address:
This project consists of three main stages:
Run build_policyid_files.py
to format and organize rule files based on the FTD Policy Name. The formatted files will be used for policy deployment.
Run payload_generator.py
to extract rule data (source, destination, ports) and create a JSON payload for API consumption. This script ensures duplicate ports are removed before sending requests to FMC.
Run PUT_acp_new_rules.py
to implement the rules on the FMC. This script:
- Creates a blank rule.
- Updates the blank rule with the payload data.
- Deploys the updated rule to the correct policy.
Executing the script:
python build_policyid_files.py
python payload_generator.py
python PUT_acp_new_rules.py
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
feature-branch
orbugfix-branch
). - Commit your changes.
- Submit a pull request with a detailed description of your changes.
Please ensure your code adheres to the project's coding standards and includes appropriate documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
- Cisco Systems for providing the Firepower Management Center API.
- The Python community for invaluable resources and libraries.
For questions or support, please open an issue on GitHub.
🚀 Automate your firewall rule management with ease!