00a95fda80
Registers {hostname}.home.dustin.coffee → host IP on boot via AdGuard Home API.
Deploy to any LXC/VM with ./install.sh — supports root (system service),
sudo user (system via sudo), and unprivileged user (systemd --user or crontab).
Files:
- adguard-register.sh — detects hostname+IP, idempotent create/update
- install.sh — deployment script with auto-detection of install method
- uninstall.sh — removes service and binary
- README.md — full documentation
Tested across 24 hosts (LXCs and VMs) on a 172.20.0.0/16 home lab network.
2.7 KiB
2.7 KiB
AdGuard Home DNS Auto-Registration
Automatically registers {hostname}.home.dustin.coffee → its own IP with AdGuard Home
DNS rewrites on boot. Designed for the home.dustin.coffee home lab domain.
How It Works
- On boot (via systemd oneshot service), the script determines the host's short hostname and primary IPv4 address
- It authenticates with the AdGuard Home API at
172.20.1.1 - It checks if a DNS rewrite for
{hostname}.home.dustin.coffeealready exists:- No entry: creates a new rewrite pointing to the current IP
- Entry exists with same IP: skips (idempotent)
- Entry exists with different IP: updates the rewrite (handles renumbering)
- Verifies the rewrite was applied successfully
The IP detection skips Docker bridges, Tailscale interfaces, and loopback to find the host's real primary address.
Deployment
On a new LXC/VM
# Copy the agent directory to the target host
scp -r adguard-register/ user@target-host:/tmp/
# SSH in and install
ssh user@target-host
cd /tmp/adguard-register
sudo ./install.sh
Manual registration (one-off, no install)
sudo /usr/local/bin/adguard-register
Uninstall
sudo /path/to/adguard-register/uninstall.sh
Requirements
curl— for API callspython3— for JSON parsingsystemd— for boot-time execution (or use@rebootcron as fallback)- Network access to
172.20.1.1:80
Files
| File | Purpose |
|---|---|
adguard-register.sh |
Main registration script |
install.sh |
Copies script to /usr/local/bin/ and sets up systemd service |
uninstall.sh |
Removes the service and script |
README.md |
This file |
Troubleshooting
Check service status
systemctl status adguard-register
journalctl -u adguard-register
Test manually
sudo /usr/local/bin/adguard-register
Common issues
- "Failed to authenticate": Verify AdGuard Home is running at
172.20.1.1and credentials are correct - "Could not determine primary IPv4 address": Ensure the host has a non-loopback, non-Docker, non-Tailscale IPv4 address
- "Verification failed": The API accepted the change but the read-back didn't match; check AdGuard Home logs
- Python3 not found: Install with
apt install python3or equivalent
AdGuard Home API Reference
- Base URL:
http://172.20.1.1/control/ - Auth:
POST /control/loginwith{"name":"...","password":"..."} - List rewrites:
GET /control/rewrite/list - Add rewrite:
POST /control/rewrite/addwith{"domain":"...","answer":"..."} - Update rewrite:
POST /control/rewrite/updatewith{"target":{"domain":"..."},"update":{"domain":"...","answer":"..."}}