Adguard CIDRE Sync

Adguard CIDRE Sync - A bot to synchronize adguard clients disallow list with countries CIDR list of your choices.

The code is partially generated by AI

Sommaire

Features

  • Automatically downloads IP CIDR blocks for specified countries to block.
  • Supports additional manually blocked IPs from a configurable file.
  • Updates the disallowed_clients section in the AdGuard Home config.
  • Configurable update frequency via cron expression environment variable.
  • Automatically restarts the AdGuard Home container after updates via Docker socket proxy.

Environment Variables

Variable Description Default
TZ Your Time Zone (required)
BLOCK_COUNTRIES Comma-separated country codes to block (e.g., CN,RU,IR) (required)
BLOCKLIST_CRON Cron expression for update frequency (e.g., 0 6 * * *) 0 6 * * * (at 6:00 everydays)
DOCKER_API_URL URL of Docker socket proxy to restart AdGuard container http://socket-proxy-adguard:2375
ADGUARD_CONTAINER_NAME Name of your adguard container adguardhome

File Structure

  • update-blocklist.sh: Main script to download CIDRs, merge manual IPs, update config, and restart AdGuard.
  • entrypoint.sh: Sets up the cron job to periodically run the update script.
  • Dockerfile: Builds the lightweight Alpine-based image.
  • docker-compose.yml: Example compose file to run the container.
  • manually_blocked_ips.conf: (Volume mount) Add extra IPs to block manually.

Installation and Usage

  1. Clone the repository:

    git clone https://git.djeex.fr/Djeex/adguard-cidre
    cd adguard-cidre
    
  2. Modify docker-compose.yml

  • Set BLOCK_COUNTRIES environment variable with the countries you want to block.

  • Adjust BLOCKLIST_CRON if you want a different update frequency.

  • Bind mount your adguard configuration folder (wich contains AdGuardHome.yaml) to /adguard

  • (optionnally) create and edit manually_blocked_ips.conf file in your adguard configuration folder to add other IPs you want to block. Only valid IP or CIDR entries will be processed, for exemple :

    192.168.1.100
    10.0.0.0/24
    # Comments or empty lines are ignored
    
  1. Build and start the container

    docker-compose build
    docker-compose up -d
    
  2. Check logs to verify updates

    docker-compose logs -f
    
Description
Adguard CIDRE Sync - A bot to synchronize adguard clients disallow list with countries CIDR list of your choices.
https://git.djeex.fr/Djeex/adguard-cidre
Readme MIT 103 KiB
v1.3 Latest
2025-06-06 14:20:38 +02:00
Languages
Python 95.8%
Dockerfile 4.2%