LinuxCommandLibrary

ahost

Lookup host IP addresses

TLDR

Print an A or AAAA record associated with a hostname or IP address

$ ahost [example.com]
copy

Display some extra debugging output
$ ahost -d [example.com]
copy

Display the record with a specified type
$ ahost -t [a|aaaa|u] [example.com]
copy

SYNOPSIS

ahost [-4] [-6] [-a] [-c class] [-t type] [-v] [-w] name [name ...]

PARAMETERS

-4
    Query only IPv4 (A) records

-6
    Query only IPv6 (AAAA) records

-a
    Query all available record types (A, AAAA, MX, NS, SOA, CNAME, PTR)

-c class
    Specify DNS class (default: IN)

-t type
    Specify record type (default: A; e.g., AAAA, MX, NS)

-v
    Enable verbose output with details like TTL and servers

-w
    Wait indefinitely for responses (no timeout)

DESCRIPTION

ahost is a command-line utility from the c-ares library, designed for performing asynchronous DNS lookups. Unlike traditional tools like host or dig, it leverages the c-ares asynchronous resolver to query multiple DNS records in parallel, making it efficient for testing and scripting scenarios requiring fast, non-blocking DNS resolutions.

It supports common record types such as A, AAAA, MX, NS, and more, with options to specify query classes and types. ahost outputs results in a concise format, showing IP addresses, TTLs, and authoritative servers when verbose mode is enabled. Ideal for developers working with async DNS in applications, it helps verify name resolution without blocking I/O.

Part of the c-ares tools suite (including adig), it's lightweight and available on most Linux distributions via the c-ares package. Use it to quickly resolve hostnames to IPs or fetch specific records asynchronously.

CAVEATS

Requires c-ares library; not installed by default on all distros. Asynchronous nature may interleave output for multiple queries. Limited to UDP queries; no TCP fallback.

EXAMPLE

ahost example.com
Outputs A records for example.com.

ahost -a -v example.com
Queries all records verbosely.

HISTORY

Developed as part of the c-ares project (2004+), a portable asynchronous DNS resolver forked from BIND9. Enhanced in c-ares 1.5+ with tools like ahost for testing; widely used in projects like Node.js and curl.

SEE ALSO

adig(1), host(1), dig(1), nslookup(1)

Copied to clipboard