tinydnsip reads a tinydns
data file (or stdin) and emits the "best" A record hostname,ip pair
for each ip on stdout.
Only lines beginning with the = or + sigil are considered; each is
parsed as {sigil}{hostname}:{ip}:{ttl}. When several hostnames map to
the same ip, the best one is chosen using these rules:
- a
=hostname beats a+hostname (first=wins) - a
+beats another+only if the hostname is strictly shorter.
A -d/--domain filter can restrict output to a given apex domain and
its subdomains.
A -o/--override file of hostname,ip records (the same shape as the
input) is applied after the input has been read. Each record is matched by
hostname: the matching entry is relocated to the override ip, keeping its
hostname. An override whose hostname is not present in the input, or that
matches more than one entry, is a fatal error. Blank lines and lines
beginning with # are ignored.
When combined with -d/--domain, override records whose hostname falls
outside the domain are silently skipped rather than treated as "not found",
so a single overrides file can be shared across domain-filtered runs.
This is useful when a host's advertised/public ip is not configured on the server itself but on a gateway or bastion in front of it. The public ip can't be validated by talking to the server directly, so an override swaps it for a reachable server ip that can be checked, while keeping the hostname the record is emitted under.
go install github.com/gavincarr/tinydnsip@latest
Gavin Carr gavin@openfusion.net
tinydnsip is available under the terms of the MIT Licence.