aboutsummaryrefslogtreecommitdiffstats
s6-dns: the s6-dnsname-filter program

s6-dns
Software
skarnet.org

The s6-dnsname-filter program

s6-dnsname-filter reads IP addresses on its standard input and prints the corresponding domain names on its standard output.

Interface

     s6-dnsname-filter [ -4 ] [ -6 ] [ -l maxlines ] [ -c maxconn ] [ -t timeout ] [ -f normalfmt ] [ -e errorfmt ]
  • s6-dnsname-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 an IP address is processed. Lines not starting with an IP address are not, and the formatting rules treat them as a pure "remainder".
  • For every processed line, the read IP address is converted to an in-addr.arpa. or ip6.arpa. domain on which a PTR query is made, and the result is printed according to the formatting rules.
  • By default, s6-dnsname-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.

Options

  • -4 : scan for IPv4 addresses.
  • -6 : scan for IPv6 addresses. Both the -4 and -6 options may be given. If none is given, by default s6-dnsname-filter will only scan for IPv4 addresses.
  • -l maxlines : maximum lines. s6-dnsname-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-dnsname-filter will stop reading from stdin before line n+maxlines, until the result arrives for line n. By default, maxlines is 256.
  • -c maxconn : maximum concurrent resolutions. s6-dnsname-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 IP address, then an equal sign, then the corresponding domain name, 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 IP address, then an equal sign, then the error message between angle brackets, then the remainder of the line.

Formatting rules

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 IP address
  • %d prints the domain name, if any
  • %e prints the error message, if any
  • %w%r prints the remainder of the input line

Notes

s6-dnsname-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.