LinuxCommandLibrary

avahi-publish-address

Publish an IP address via Avahi

SYNOPSIS

avahi-publish-address [OPTIONS] <hostname> <address>

<hostname>: The mDNS hostname (e.g., "mydevice") to publish. This will typically resolve as "mydevice.local".
<address>: The IP address (e.g., "192.168.1.100" or "fe80::1") to associate with the hostname.

PARAMETERS

-h, --help
    Show a help message and exit.

-v, --version
    Show the version number and exit.

-D, --daemonize
    Detach from the controlling terminal and run as a daemon in the background.

-d, --domain=DOMAIN
    Specify the mDNS domain name to register in (defaults to 'local').

-P, --proto=PROTO
    Specify the IP protocol to publish ('ipv4' or 'ipv6'). By default, it publishes for both if the address type is ambiguous.

-V, --ttl=SECONDS
    Set the DNS Time To Live (TTL) for the published record in seconds (defaults to 120).

-e, --no-reverse
    Do not publish a reverse DNS (PTR) entry for the address.

-n, --no-wait
    Do not wait for the Avahi daemon to start before attempting to publish.

DESCRIPTION

avahi-publish-address is a utility from the Avahi project, designed to publish a specific network address (IPv4 or IPv6) associated with a given hostname on a local network using Multicast DNS (mDNS). mDNS allows devices to discover each other and their services without requiring a central DNS server. When you run this command, it announces that <hostname>.local (or a specified domain) resolves to <address>. This makes the device discoverable by other Avahi/Bonjour-enabled clients on the same local subnet. It's commonly used for headless devices or services that need to announce their presence and IP address in a zero-configuration networking environment. The command remains active, continuously publishing the address until it's terminated, ensuring ongoing discoverability.

CAVEATS

The avahi-daemon service must be running for avahi-publish-address to function. If the specified hostname is already taken on the local network, Avahi's conflict resolution mechanism will typically try to append a number (e.g., 'mydevice-2.local') to ensure uniqueness. However, this command will continue to try publishing the exact name given if it's explicitly provided, which might lead to issues if another device is also publishing the same name. It is designed to be run as a long-lived process to maintain the advertisement.

EXAMPLE USAGE

To publish the hostname mydevice.local with the IPv4 address 192.168.1.100:

avahi-publish-address mydevice 192.168.1.100

To run this in the background as a daemon:

avahi-publish-address -D mydevice 192.168.1.100

To publish an IPv6 address:

avahi-publish-address -P ipv6 myipv6host fe80::1234:5678:9abc:def0

INTERACTION WITH /ETC/HOSTS

mDNS entries published via Avahi operate independently of the /etc/hosts file. While /etc/hosts provides static local hostname-to-IP mappings, Avahi provides dynamic, network-wide discovery. They serve different purposes, though both can be used for name resolution.

HISTORY

avahi-publish-address is part of the Avahi project, which started in 2004 as a free software implementation of Apple's Bonjour (formerly Rendezvous) zero-configuration networking specification. It aims to provide seamless service discovery and device resolution on local networks, primarily for Linux and other Unix-like operating systems. The command's core functionality has remained consistent, serving as a fundamental tool for advertising hostnames and IP addresses.

SEE ALSO

Copied to clipboard