checkzone from stdin?

Anand Buddhdev anandb at ripe.net
Wed Apr 8 19:55:22 UTC 2020


On 08/04/2020 20:58, Matthew Pounsett wrote:

> It looks to me like named-checkzone isn't able to read a zone file from
> stdin.
> 
> % cat example.com.db | named-checkzone example.com -
> zone example.com/IN: loading from master file - failed: file not found
> zone example.com/IN: not loaded due to errors.

Hi Matt,

named-checkzone wants a file, so give it a "file":

named-checkzone ripe.net. /dev/stdin < ripe.net.zone

Note that it would work with "cat file | ..." but I absolutely hate the
cat-pipe combination. I've been known to mark down interviewees who
offer a solution that involves cats and pipes :)

If you want to feed a compressed zone file, then of course a gzcat-pipe
combination will work, eg:

gzcat ripe.net.zone.gz | named-checkzone ripe.net. /dev/stdin

Finally, if you're running your scripts under bash, then bash offers a
very neat feature:

named-checkzone ripe.net. <(gzcat ripe.net.zone.gz)

The "<(...)" construct in bash runs the command inside the parantheses,
and sends its output to an ephemeral file of the form /dev/fd/42. So the
above command becomes:

named-checkzone ripe.net. /dev/fd/42

and named-checkzone reads the "file" /dev/fd/42, getting the
decompressed data.

Regards,
Anand Buddhdev
RIPE NCC


More information about the bind-users mailing list