# AdGuard DNS Rewrite Sync Tool This script synchronizes DNS rewrite rules between a local YAML configuration and an AdGuard Home instance using its REST API. ## Features - Logs into AdGuard Home via its control API - Loads desired DNS rewrite entries from a YAML file - Retrieves current DNS rewrite rules from AdGuard - Compares current vs. desired state and: - Adds new entries - Updates existing ones with changed IPs - Deletes entries no longer needed - Merges local and remote rules and writes back to the YAML file ## Requirements - Python 3.7+ - [`requests`](https://pypi.org/project/requests/) - [`pyyaml`](https://pypi.org/project/PyYAML/) - [`python-dotenv`](https://pypi.org/project/python-dotenv/) Install dependencies: ```bash pip install -r requirements.txt ## Configuration Create a .env file in the same directory with the following variables: ```env ADGUARD_URL=http://:3000 ADGUARD_USER=admin PASSWORD=yourpassword YAML_FILE=rewrites.yaml ``` # YAML File Format The YAML file should contain rewrite entries under the rewrites key: ```yaml rewrites: - domain: "example.org" answer: "127.0.0.1" - domain: "another.example.org" answer: "192.168.1.1" ``` # Usage Run the script: ```bash python main.py ```