Network Configuration Compliance Checker
The Network Configuration Compliance Checker is a Python-based tool designed to analyze and validate network device configurations against predefined security and operational policies. It ensures compliance with industry best practices and aids in maintaining secure and consistent network environments.
This tool is particularly useful for network administrators and IT teams seeking to automate configuration validation, identify misconfigurations, and ensure policy adherence across multi-vendor environments.
Features
- Parse and validate router/switch configurations against YAML-defined policies.
- Supports multi-vendor environments, including Cisco, Juniper, and others.
- Generates detailed compliance reports in both text and JSON formats.
- Extendable with custom policies for diverse use cases.
- Future support for:
- Real-time configuration monitoring.
- Notifications via email or Slack.
- A web interface for managing configurations and reports.
Installation
Prerequisites
- Python 3.8 or higher.
- Network device configurations saved in plain text format.
- Policies defined in YAML files.
Clone the Repository
git clone https://github.com/akintunero/network-config-checker.git
cd network-config-checker
Create a Virtual Environment (Recommended)
python -m venv venv
source venv/bin/activate # For macOS/Linux
venv\Scripts\activate # For Windows
Install Required Libraries
The following Python libraries are required:
pyyaml
netmiko
napalm
schedule
Install all dependencies using:
pip install -r requirements.txt
Usage
- Define Your Policies
Create a YAML file containing your security and operational policies. Example:
require_interface_description:
description: "Ensure all interfaces have descriptions."
conditions:
- "description"
require_ip_address:
description: "Ensure all interfaces have an IP address."
conditions:
- "ip address"
- Save this file in the policies/ directory, e.g., policies/security_policies.yaml
- Prepare Configuration Files
Save your router or switch configuration in text format. Example:
interface GigabitEthernet0/1
description Uplink to Core
ip address 192.168.1.1 255.255.255.0
- Place the configuration files in the config_samples/ directory.
- Run the Compliance Checker
To analyze a configuration file against your policies, use the Command Line Interface (CLI):
python src/main.py --config config_samples/sample_config.txt --policy policies/security_policies.yaml
Output Example
- Text Report: reports/compliance_report.txt
- JSON Report: reports/compliance_report.json
Advanced Usage with Network Devices
Fetch Configuration from a Cisco Router:
python src/live_monitor.py --device cisco_router --ip 192.168.1.1 --username admin --password secret
Fetch Configuration from a Juniper Switch:
python src/live_monitor.py --device juniper_switch --ip 192.168.2.1 --username admin --password secret
Testing
Unit tests are available to validate the tool's functionality. Run the following command:
pytest tests/
Configuration File Format
- Each configuration file should follow the plain text format typical for router/switch configurations.
- Ensure configurations are compatible with the device vendor's standards.
Example:
interface GigabitEthernet0/2
description Connection to ISP
ip address 10.0.0.1 255.255.255.0
Policy File Structure
Policies are defined in YAML format and specify conditions to validate configurations.
- Each policy must have:
- A unique identifier as the key.
- A description of the policy.
- A list of conditions to validate.
Example:
require_vlan_configuration:
description: "Ensure VLANs are configured properly."
conditions:
- "vlan"
- "name"
Error Handling
The tool provides error messages for:
- Missing or invalid configuration files.
- Malformed policy files.
- Unrecognized commands or parameters.
Ensure all files follow the specified formats to avoid errors. Security Considerations
- Avoid hardcoding sensitive credentials (e.g., passwords) in scripts or files.
- Use encrypted storage or environment variables for sensitive information.
- Restrict access to the tool and configuration files to authorized users only.
Troubleshooting
Common Issues
- Missing Dependencies: Ensure all required libraries are installed using:
pip install -r requirements.txt - File Not Found: Verify the paths to configuration and policy files.
- Invalid Policy Format: Ensure your YAML policies are correctly structured.
Future Improvements
- Real-Time Monitoring: Continuously fetch and validate configurations.
- Notification System: Alert users of policy violations via email or Slack.
- Web Interface: Provide a dashboard for uploading files, viewing reports, and monitoring compliance.
Compatibility
The tool supports configurations from:
- Cisco routers and switches.
- Juniper switches.
- Additional vendors can be supported by extending the tool's parsing logic.
Contributing
Contributions are welcome! To contribute by submitting a pull request
License
This project is licensed under the MIT License.
Metadata
Release files for network-config-checker 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| network-config-checker-0.1.0.tar.gz | 4.2 kB | Without provenance | Details for network-config-checker-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| network_config_checker-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for network_config_checker-0.1.0-py3-none-any.whl |
Total release size: 7.9 kB
Release files / network-config-checker-0.1.0.tar.gz
| Download URL | network-config-checker-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
552d02ab1db01e78738b404bb0e0140aad2817642aa197f331a46544c7323c9b
|
|
BLAKE2b-256 checksum How to use checksums |
240ed39c21e3878a98a0a5486acaf5fee2743ea044971778883ae5660000fe1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.10
|
Release files / network_config_checker-0.1.0-py3-none-any.whl
| Download URL | network_config_checker-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b476c172b50d6c91a08991b1bd0d76c13f0d2c0098d6533b75f2acd1b5f2b53
|
|
BLAKE2b-256 checksum How to use checksums |
c63620c36db4464b9bca78ecf98047ea9ae8b5d8cfca62e40213b49e21642aed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.8.10
|
Security for network-config-checker 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.