---
title: Adguard CIDRE
description: A Python script to sync AdGuard Home CIDR allowlists automatically, securing your self-hosted DNS server exposed to the internet.
---


:ellipsis{left=0px width=40rem top=10rem blur=140px zIndex=60}
# 🤖 Adguard CIDRE Sync
---

Adguard Home is a fantastic solution for DNS-level ad blocking and rewriting requests—perfect for removing ISP DNS trackers or intrusive ads.

It works great locally, but if you want all your devices (even on the go) to benefit, you’ll need to expose Adguard to the internet. Unfortunately, that means anyone can use it, potentially overloading your €1/month remote VPS.

Adguard allows whitelisting or blacklisting clients. The problem? To whitelist a client, you need their IP—but for mobile phones, that IP changes often. Instead of trying to whitelist ever-changing IPs, the better approach is to block broader IP ranges by region.

CIDRE is a tool that syncs geo-targeted IP ranges with firewalls. Instead of running CIDRE with a full firewall stack on the remote server, I figured I could just import those regularly updated IP ranges into Adguard’s blocklist.

Thus, Adguard CIDRE Sync was born: a container that syncs Adguard’s blocklist with CIDRE’s updated IP ranges on a schedule of your choosing.

The idea is to:

- Backup Adguard’s config file on first run (original untouched version saved)
- Download selected country IP ranges via an environment variable
- Let you manually add custom IPs via a file
- Concatenate, backup the config again (as the updated version), and inject the list into the correct blocklist section
- Reload Adguard by restarting the container (using Docker socket proxy for limited permissions)

All fully autonomous, with frequency set via environment variable in the `docker-compose` config.

More info directly on the repo:

::card{title="🐋 __Adguard CIDRE Sync__" to="https://git.djeex.fr/Djeex/adguard-cidre" target="_blank"}
Adguard blocklist sync bot
::
