The s6-dnsip4-filter program
s6-dnsip4-filter reads domain names on its standard input and
prints the corresponding IPv4 addresses on its standard output.
s6-dnsip4-filter [ -l maxlines ] [ -c maxconn ] [ -t timeout ] [ -f normalfmt ] [ -e errorfmt ]
- s6-dnsip4-filter reads lines from its stdin, processes them, and prints
the processed lines to its stdout, in the same order. It exits 0 when it
reads EOF on stdin.
- Every line starting with a domain name is processed. Lines not
starting with a domain name are not, and the formatting rules treat them
as a pure "remainder".
- For every processed line, an A query is made, and the result is
printed according to the formatting rules. The domain is not qualified
before being resolved.
- By default, s6-dnsip4-filter looks for DNS cache addresses in the
/etc/resolv.conf file. If the DNSCACHEIP environment variable is set
and contains a list of IP (v4 or v6) addresses, separated by commas,
semicolons, spaces, tabs, newlines or carriage returns, then this list
is used instead.
- -l maxlines : maximum lines. s6-dnsip4-filter
will keep at most maxlines lines in memory at the same time. If line
n is still waiting for resolution and cannot be printed, then
s6-dnsip4-filter will stop reading from stdin before line n+maxlines,
until the result arrives for line n. By default, maxlines
- -c maxconn : maximum concurrent resolutions.
s6-dnsip4-filter will perform at most maxconn resolutions in
parallel at the same time. maxlines cannot be lesser than maxconn.
By default, maxconn is 128.
- -t timeout : if any resolution takes more
than timeout milliseconds, then it is aborted and printed as a
timeout error. By default, timeout is 0, which means no timeout.
- -f normalfmt : print the positive results according to
the normalfmt format string. By default, normalfmt is
%s=%d%w%r, which means: print the original domain name, then an equal
sign, then the corresponding IPv4 address, then the remainder of the line.
- -e errorfmt : print the negative results according to
the errorfmt format string. By default, errorfmt is
%s=<%e%>%w%r, which means: print the original domain name, then an equal
sign, then the error message between angle brackets, then the remainder of the line.
normalfmt and errorfmt are format strings, i.e. they tell the
program how a line must be printed. The following sequences are recognized:
- %% prints a single % character
- %s prints the original domain name
- %d prints the IP address, if any
- %e prints the error message, if any
- %w%r prints the remainder of the input line
s6-dnsns google.com | s6-dnsip4-filter -f "%d"
prints all the nameserver addresses for the google.com
domain. This is useful, for instance, to give the result as an
argument to s6-dnsq.
s6-dnsip4-filter does not perform DNS resolutions itself. Instead, it forks
a skadnsd child and sends it queries, getting
the results asynchronously. The s6-dns filter programs have actually been
written as example uses of the skadns library.