Entry
How can I send a recursive query to a specific server?
Nov 20th, 2003 03:59
Jonathan de Boyne Pollard, Brian Coogan, Rob Mayoff,
This is useful when testing DNS servers.
Unlike dnsq, the dnsqr command does not accept the DNS server
address as a command-line argument. It normally finds the DNS
server address in /etc/resolv.conf.
However, you can easily override /etc/resolv.conf by putting an
IP address in the environment variable DNSCACHEIP. In
Bourne-type shells (sh, ash, bash, ksh, zsh), you can just do
this:
DNSCACHEIP=1.2.3.4 dnsqr a example.com
That will send a recursive query for example.com's A records to
1.2.3.4.
In csh-type shells (works for all shell types), you can do
this:
env DNSCACHEIP=1.2.3.4 dnsqr a example.com
Whatever shell you use, you can also create a shell script
called "dnsr" that acts just like dnsq:
#!/bin/sh
DNSCACHEIP=`dnsip "$3"`
if [ "$DNSCACHEIP" = "" ]; then
DNSCACHEIP=0.0.0.0
fi
export DNSCACHEIP
exec dnsqr "$1" "$2"
Because it uses the output from "dnsip" directly as the value
for the environment variable, the same caveat, about providing
as the third argument domain names that map to more than one IP
address, that applies to the "dnsqrx" script at
http://homepages.tesco.net./~J.deBoynePollard/Softwares/djbdns.
html#dnsqrx
also applies to this script.