---
name: "dnsquery"
section: "1bind"
platform: "linux"
package: "bind"
version: "1:8.2.2p5-0slink1.1"
release: "Debian 2.1 (Slink)"
platforms: ["linux"]
url: "https://new.carta.tech/dnsquery/1bind"
---

# dnsquery(1bind)

query domain name servers using resolver

## NAME

**dnsquery** – query domain name servers using resolver

## SYNOPSIS

**dnsquery** \[**-n** *nameserver*\] \[**-t** *type*\] \[**-c** *class*\] \[**-r** *retry*\] \[**-p** *period*\] \[**-d**\] \[**-s**\] \[**-v**\] *host*

## DESCRIPTION

The **dnsquery** program is a general interface to nameservers via BIND resolver library calls.  The program supports queries to the nameserver with an opcode of QUERY. This program is intended to be a replacement or supplement to programs like nstest, nsquery and nslookup.  All arguments except for *host* and *nameserver* are treated without case-sensitivity.

## OPTIONS

- **-n** *nameserver*

  The nameserver to be used in the query.  Nameservers can appear as either  Internet addresses of the form  *w.x.y.z* or can appear as domain names. (Default: as specified in  */etc/resolv.conf*.)

- **-t** *type*

  The type of resource record of interest.  Types include:

  - *A*

    address

  - *NS*

    nameserver

  - *CNAME*

    canonical name

  - *PTR*

    domain name pointer

  - *SOA*

    start of authority

  - *WKS*

    well-known service

  - *HINFO*

    host information

  - *MINFO*

    mailbox information

  - *MX*

    mail exchange

  - *RP*

    responsible person

  - *MG*

    mail group member

  - *AFSDB*

    DCE or AFS server

  - *ANY*

    wildcard

    Note that any case may be used.  (Default:   *ANY*.)

- **-c** *class*

  The class of resource records of interest. Classes include:

  - *IN*

    Internet

  - *HS*

    Hesiod

  - *CHAOS*

    Chaos

  - *ANY*

    wildcard

    Note that any case may be used.  (Default:   *IN*.)

- **-r** *retry*

  The number of times to retry if the nameserver is not responding.  (Default:  4.)

- **-p** *period*

  Period to wait before timing out.  (Default:   RES\_TIMEOUT.)

- **-d**

  Turn on debugging.  This sets the  RES\_DEBUG bit of the resolver's *options* field.  (Default:  no debugging.)

- **-s**

  Use a *stream* rather than a packet.  This uses a TCP stream connection with the nameserver rather than a UDP datagram.  This sets the RES\_USEVC bit of the resolver's *options* field.  (Default:  UDP datagram.)

- **-v**

  Synonym for the  “**-s**” flag.

- *host*

  The name of the host (or domain) of interest.

## FILES

- */etc/resolv.conf*

  to get the default ns and search lists

- *\<arpa/nameser.h\>*

  list of usable RR types and classes

- *\<resolv.h\>*

  list of resolver flags

## DIAGNOSTICS

If the resolver fails to answer the query and debugging has not been turned on, **dnsquery** will simply print a message like:

```
Query failed (rc = 1): Unknown host
```

The value of the return code is supplied by  *h\_errno*.

## SEE ALSO

nslookup(@SYS\_OPS\_EXT@), nstest(@CMD\_EXT@), nsquery(@CMD\_EXT@), named(@SYS\_OPS\_EXT@), resolver(@FORMAT\_EXT@).

## AUTHOR

Bryan Beecher

## BUGS

Queries of a class other than  *IN* can have interesting results since ordinarily a nameserver only has a list of root nameservers for class  *IN* resource records.

**Dnsquery** uses a call to  **inet\_addr**() to determine if the argument for the  “**-n**” option is a valid Internet address.  Unfortunately, **inet\_addr**() seems to cause a segmentation fault with some (bad) IP addresses (e.g., 1.2.3.4.5).
