LinuxCommandLibrary

avahi-set-host-name

Set the machine's Avahi host name

SYNOPSIS

avahi-set-host-name NEW_HOSTNAME

PARAMETERS

NEW_HOSTNAME
    The desired new hostname (a string) that Avahi should advertise on the network. This name will be used in mDNS records.

DESCRIPTION

The avahi-set-host-name command is a utility for dynamically updating the hostname that the Avahi daemon advertises on a network using mDNS (Multicast DNS) and DNS-SD (DNS Service Discovery). Avahi is an open-source implementation of Apple's Bonjour zero-configuration networking. While Linux systems typically manage their primary hostname via commands like hostnamectl or by modifying /etc/hostname, these changes often require a system reboot or a restart of various services to take full effect.

avahi-set-host-name provides a way to tell the running Avahi daemon to immediately begin advertising a new hostname without requiring a restart of the avahi-daemon service. It does this by communicating with the daemon over D-Bus, triggering an update to the mDNS records (A and AAAA records) broadcast for the host. This is particularly useful in environments where the machine's perceived name on the local network needs to change without impacting its static system hostname or disrupting other services. It's crucial to understand that this command only affects Avahi's broadcasted name, not the system's persistent hostname.

CAVEATS

Requires the avahi-daemon service to be actively running in the background for the command to function. If the daemon is not running, the command will fail.
This command modifies only the hostname advertised by Avahi via mDNS/DNS-SD; it does not change the system's static hostname (e.g., as set in /etc/hostname or reported by hostnamectl).
Typically requires root privileges to execute successfully, as it interacts with the system-wide Avahi daemon via D-Bus.
The new hostname must be a valid DNS label (e.g., alphanumeric, hyphens, no underscores, max 63 characters per label).

INTERACTION WITH D-BUS

The avahi-set-host-name command communicates with the running avahi-daemon through the D-Bus message bus system. It sends a D-Bus method call to the daemon to request a hostname update, which then triggers the daemon to send out new mDNS records reflecting the change. This mechanism allows for dynamic updates without interrupting the daemon's operation.

SCOPE OF HOSTNAME CHANGE

It's critical to understand that the hostname updated by avahi-set-host-name is specifically the name advertised through Avahi's mDNS services. This name is primarily used by other mDNS-aware devices on the local network to discover and connect to your machine by name. It does not alter the system's static hostname (the name returned by hostname or hostnamectl or found in /etc/hostname), which is used for other system-level operations and configurations.

HISTORY

The avahi-set-host-name utility is an integral part of the Avahi project, which was started around 2004. Avahi itself originated from the mDNSResponderposix project and was conceived to provide a free and open-source implementation of Zeroconf (Zero Configuration Networking) technologies, specifically mDNS and DNS-SD, for Linux and other Unix-like systems. This command was developed as a simple, direct interface to update the Avahi daemon's advertised hostname at runtime, avoiding the need for service restarts that would typically be required for system hostname changes. Its inclusion reflects the Avahi project's commitment to providing flexible and dynamic network service configuration.

SEE ALSO

avahi-daemon(8), hostname(1), hostnamectl(1), nss-mdns(5), dbus-send(1)

Copied to clipboard