Pi-hole, Unbound, and Turkey's official USOM API
Contents
I wanted every device on my home network to resolve DNS through one place I control, without installing browser extensions on phones or smart TVs and without sending every lookup to my ISP or a third-party resolver. Moving DNS and DHCP from the router to a small Debian 13 server running Pi-hole v6 and Unbound solved that, and left one extra problem: Turkey’s national CERT (USOM) retired its plain-text blocklist (usom.gov.tr/url-list.txt) on June 1, 2026 and moved everything to a JSON REST API at siberguvenlik.gov.tr.
Rather than trusting an unofficial GitHub mirror, I wrote a small Python script that pulls the official API directly into a local blocklist file for Pi-hole and updates it daily.
Pi-hole v6 and local Unbound
Pi-hole handles DHCP for the LAN (home.arpa), filters known ad, tracker, and malicious domains, and forwards clean queries to Unbound listening only on localhost port 5335. Unbound resolves names recursively from the root servers and checks DNSSEC signatures itself.
The Unbound drop-in at /etc/unbound/unbound.conf.d/pi-hole.conf keeps the config minimal:
server:
verbosity: 0
interface: 127.0.0.1
port: 5335
do-ip4: yes
do-udp: yes
do-tcp: yes
harden-glue: yes
harden-dnssec-stripped: yes
edns-buffer-size: 1232
prefetch: yes
private-address: 192.168.0.0/16
private-address: 172.16.0.0/12
private-address: 10.0.0.0/8
In Pi-hole v6, setting dns.upstreams to ["127.0.0.1#5335"] and enabling DHCP ensures every device on the LAN picks up the server automatically.
Syncing the official TR-CERT API into Pi-hole
The official notice on usom.gov.tr/adres states that .txt list downloads ended on June 1, 2026 and directs integrators to https://siberguvenlik.gov.tr/api/address/index. That endpoint requires no API key, supports type=domain, date_gte, and per-page up to 9999.
Testing it live showed three practical details I had to handle in /usr/local/bin/usom-pihole-sync:
- Pulling all historical entries back to 2014 meant nearly half a million domains, many long expired. Filtering to the last 365 days (
date_gte) brings it down to roughly 58,000 active domains across six API pages. - Sending requests back to back triggered
Connection reset by peer, so the script pauses 1.5 seconds between pages and retries with backoff. - A handful of records under
type=domainare not valid hostnames, so a strict regex strips malformed lines before writing atomically via a temporary file.
The core sync logic uses only the Python standard library:
API_URL = "https://siberguvenlik.gov.tr/api/address/index"
DOMAIN_RE = re.compile(
r"^(?=.{4,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$"
)
def fetch_page(date_gte: str, page: int, per_page: int = 9999) -> dict:
query = urllib.parse.urlencode(
{"type": "domain", "date_gte": date_gte, "per-page": per_page, "page": page}
)
req = urllib.request.Request(
f"{API_URL}?{query}",
headers={"User-Agent": "usom-pihole-sync/1.0", "Accept": "application/json"},
)
for attempt in range(1, 4):
try:
with urllib.request.urlopen(req, timeout=25) as resp:
return json.loads(resp.read().decode("utf-8"))
except (urllib.error.URLError, TimeoutError, ConnectionResetError):
if attempt < 3:
time.sleep(2 * attempt)
raise RuntimeError(f"failed to fetch page {page}")
Running the script writes /var/lib/pihole-usom/usom-domains.txt (0644), and a daily systemd timer runs it with --update-gravity (pihole -g). Adding file:///var/lib/pihole-usom/usom-domains.txt as a blocklist in Pi-hole loads all ~58,000 domains alongside StevenBlack, HaGeZi Multi, and Perflyst SmartTV with zero invalid entries.

Verification
First I checked that Unbound validates DNSSEC properly (accepting a valid signed record with the ad flag and rejecting a broken signature with SERVFAIL):
dig @127.0.0.1 -p 5335 sigok.verteiltesysteme.net +dnssec | grep -E "status:|flags:"
# ;; ->>HEADER<<- opcode: QUERY, status: NOERROR
# ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
dig @127.0.0.1 -p 5335 sigfail.verteiltesysteme.net | grep status:
# ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL
Then I tested a Turkish bank-phishing domain (garanti.giris.yansitek.cam) added to the official list three days earlier:
dig @127.0.0.1 garanti.giris.yansitek.cam +short
# 0.0.0.0
sudo pihole -q garanti.giris.yansitek.cam
# Found 1 lists exactly matching 'garanti.giris.yansitek.cam'.
# - file:///var/lib/pihole-usom/usom-domains.txt (block)
Neither StevenBlack nor HaGeZi contained that local phishing domain; only the synced TR-CERT list caught it. Across 24 devices on the LAN over a 30-day window, the server handled roughly 577,000 queries and blocked 4.4% of them with no false-positive breakages so far.