LinuxCommandLibrary

avahi-resolve

Resolve Avahi (mDNS) hostnames and addresses

TLDR

Resolve a local service to its IPv4

$ avahi-resolve -4 [[-n|--name]] [service.local]
copy

Resolve an IP to a hostname, verbosely
$ avahi-resolve [[-v|--verbose]] [[-a|--address]] [IP]
copy

SYNOPSIS

avahi-resolve [options] [hostname ...]

PARAMETERS

-h, --help
    Show brief help text

--version
    Show version information

-v, --verbose
    Enable verbose output

-a, --address
    Resolve IP address to hostname (reverse lookup)

-n, --name
    Resolve service name via PTR lookup

DESCRIPTION

avahi-resolve is a lightweight command-line tool from the Avahi suite, implementing multicast DNS (mDNS) resolution on Linux and Unix-like systems. It queries the avahi-daemon to map local hostnames—typically ending in .local—to IP addresses (IPv4/IPv6), or perform reverse lookups. This enables Zeroconf networking in environments without central DNS, like home LANs, where devices self-advertise via mDNS.

Default usage resolves hostnames to addresses, outputting one per line. The -a option inverts this for IP-to-hostname resolution, while -n handles service types (PTR records) for network service discovery. Verbose mode aids debugging. Ideal for scripts automating device detection, such as finding printers or media servers.

Avahi bridges Apple's Bonjour protocol to Linux, ensuring compatibility. It relies on the daemon for caching and multicast queries, supporting seamless local communication across wired/wireless networks.

CAVEATS

Requires running avahi-daemon. Limited to mDNS (.local) domains; ineffective across routed subnets without IGMP/mDNS forwarding. Caches may cause stale results.

EXAMPLES

avahi-resolve laptop.local
192.168.1.100 laptop.local

avahi-resolve -a 192.168.1.100
laptop.local

avahi-resolve -n _http._tcp.local

DEPENDENCIES

Needs libavahi-client3 and avahi-daemon; configure /etc/nsswitch.conf with mdns4_minimal [NOTFOUND=return] for system-wide resolution.

HISTORY

Debuted in Avahi 0.1 (2004), core to the project by Lennart Poettering and Collabora for Linux Zeroconf support; stable since 0.6 (2005).

SEE ALSO

avahi-browse(1), avahi-publish(1), avahi-daemon(8), nss-mdns(8), host(1)

Copied to clipboard