I am writing a dns tool and require "| xargs host" and this works however the host command is doing the lookups agains the dns servers configured in /etc/resolv.conf.
I was running some tests and read the man page for xargs but cant figure out how to specify the dns server with host + xargs.
printf "google.com\nyahoo.com\nbing.com\n" > hosts.txt cat hosts.txt | xargs -n1 host
This will lookup the 3 domains and output, but the dns server doing the lookup is the one configured under /etc/resolv.conf
To specify a dns server with host you typically just append the server at the end of the command:
"host google.com 22.214.171.124"
I am looking for something like this:
server_to_query=126.96.36.199 ; cat hosts.txt | xargs -n1 host [xargs input] $server_to_query
However, this is what is happening:
server_to_query=188.8.131.52 ; cat hosts.txt | xargs -n1 host $server_to_query [xargs input]
Results are $server_to_query is being looked up against [xargs input] and I'm looking for the opposite to happen.
If I cant do it with xargs I suppose I can just use a for loop, or use dig, but would prefer to use xargs and host.