SUNWcsu
nstest is an interactive DNS test program. Queries are formed and sent by user command; any reply received is printed on the standard output. inet_addr is the Internet address of the DNS resolver to which nstest should send its queries. If inet_addr is not included, nstest first tries to contact a DNS server on the local host; if that fails, it tries the servers listed in the /etc/resolv.conf file. If a logfile is supplied, nstest uses it to log the queries sent and replies received.
When nstest starts, it prints a prompt (">") and waits for user input. DNS queries are formed by typing a key letter followed by the appropriate argument. Each key letter results in a call to res_mkquery () with op set to either IQUERY or QUERY and type set to one of the type values (defined in <arpa/nameser.h>). (Any other key letter than those listed below causes nstest to print a summary of the following table.)
Key Letter & Argument Op Type ahost QUERY T_A Aaddr IQUERY T_A Buser QUERY T_MG buser QUERY T_MB chost QUERY T_CNAME fhost QUERY T_UINFO Ggid IQUERY T_GID ghost QUERY T_GID hhost QUERY T_HINFO ihost QUERY T_MINFO Mhost QUERY T_MAILB mhost QUERY T_MX nhost QUERY T_NS phost QUERY T_PTR rhost QUERY T_MR shost QUERY T_SOA Thost QUERY T_TXT Uuid IQUERY T_UID uhost QUERY T_UID whost QUERY T_WKS xhost QUERY T_AXFR
After the query is successfully formed, res_send () is called to send it and wait for a reply. nstest then prints the following on the standard output:
To fetch the address of host playground.sun.com from the Sun name server, the user would enter:
$ nstest 192.9.5.1 > aplayground.sun.com
nstest would return the following:
res_mkquery(0, playground.sun.com, 1, 1) res_send() HEADER: opcode = QUERY, id = 1, rcode = NOERROR header flags: rd qdcount = 1, ancount = 0, nscount = 0, arcount = 0 QUESTIONS: playground.sun.com, type = A, class = IN Querying server (# 1) address = 192.9.5.1 got answer: HEADER: opcode = QUERY, id = 1, rcode = NOERROR header flags: qr aa rd ra qdcount = 1, ancount = 1, nscount = 0, arcount = 0 QUESTIONS: playground.sun.com, type = A, class = IN ANSWERS: playground.sun.com type = A, class = IN, ttl = 1 day, dlen = 4 internet address = 192.9.5.5
To look up a PTR record, enter:
$ nstest 192.9.5.1 > p5.5.9.192.in-addr.arpa
nstest would return the following:
res_mkquery(0, 5.5.9.192.in-addr.arpa, 1, 12) res_send() HEADER: opcode = QUERY, id = 2, rcode = NOERROR header flags: rd qdcount = 1, ancount = 0, nscount = 0, arcount = 0 QUESTIONS: 5.5.9.192.in-addr.arpa, type = PTR, class = IN Querying server (# 1) address = 192.9.5.1 got answer: HEADER: opcode = QUERY, id = 2, rcode = NOERROR header flags: qr aa rd ra qdcount = 1, ancount = 1, nscount = 0, arcount = 0 QUESTIONS: 5.5.9.192.in-addr.arpa, type = PTR, class = IN ANSWERS: 5.5.9.192.in-addr.arpa type = PTR, class = IN, ttl = 7 hours 47 mins 2 secs, dlen = 23 domain name = playground.sun.com