This script is designed to manage IPv6 prefix delegation using a MySQL database. It supports assigning random prefixes to users, checking for recently revoked prefixes, and revoking prefixes for removed users.
- Assign IPv6 prefixes to users who don't already have one.
- Revoke prefixes when users are removed from the
radchecktable. - Avoid reassigning recently revoked prefixes.
- Supports hierarchical delegation of IPv6 subnets based on parent prefixes.
The script requires a config.yaml file with the following structure:
database:
host: "your_database_host"
port: 3306
user: "your_username"
password: "your_password"
database: "your_database_name"
revocation_period_days: 90
prefixes:
- parent_prefix: "2001:db8:c000::/34"
delegation_length: 48database: Connection details for the MySQL database.revocation_period_days: Number of days after which a revoked prefix can be reassigned.prefixes: A list of parent prefixes and their respective delegation lengths.
- Python 3.8 or higher
- The following Python libraries:
ipaddressdatetimerandomloggingpyyamlpymysql
Install dependencies using pip:
pip3 install -r requirements.txt -U- Create and configure the
config.yamlfile. - Run the script:
python3 app.pyThe script logs important events, including successful prefix assignments and revocations. Logs are displayed on the console in the format:
YYYY-MM-DD HH:MM:SS - LEVEL - MessageThe script interacts with the following database tables:
radcheck: Contains user credentials.radreply: Stores assigned IPv6 prefixes.delegated_prefixes: Tracks prefix assignments and revocation dates.
This script is open-source and licensed under the MIT License. See the LICENSE file for details.