avahi-publish
Publish network services using Avahi (mDNS/DNS-SD)
SYNOPSIS
avahi-publish [OPTIONS] <mode> ...
<mode> can be one of the following:
-s, --service <name> <type> <port> [interface] [host] [domain] [TXT ...]
-S, --address <name> <address>
PARAMETERS
-s, --service <name> <type> <port> [interface] [host] [domain] [TXT ...]
Publishes a DNS-SD service record. <name> is the human-readable service name, <type> is the service type (e.g., _http._tcp), and <port> is the service's port number. Optional arguments include the network interface, the host's name, the domain, and arbitrary TXT record key-value pairs.
-S, --address <name> <address>
Publishes an address record (A/AAAA record). <name> is the hostname to advertise, and <address> is the IP address (IPv4 or IPv6) associated with it.
-H, --host <host>
Specifies the host name to use for the service record instead of the local machine's default hostname. Only applicable when publishing a service.
-P, --protocol <protocol>
Specifies the IP protocol to use for publishing: ipv4, ipv6, or all (default).
-t, --ttl <seconds>
Sets the Time-To-Live (TTL) for the published DNS records in seconds. The default is typically 10 seconds for mDNS records.
-d, --daemonize
Detaches the process from the controlling terminal and runs in the background. When daemonized, the publication will persist until the background process is stopped.
-p, --pidfile <file>
Writes the process ID (PID) to the specified file when daemonized.
-c, --no-chroot
Disables chrooting. By default, avahi-publish attempts to chroot for security reasons if it drops root privileges.
-C, --no-drop-root
Disables dropping root privileges. By default, avahi-publish attempts to drop root privileges after binding to network ports for enhanced security.
-e, --no-fail
Does not exit immediately if it fails to bind to a network port or encounters another error. It will keep trying to publish.
-v, --verbose
Enables verbose output, printing more information about the publishing process to the console.
-V, --version
Shows the version number of the avahi-publish utility and exits.
-h, --help
Displays a help message with usage information and available options, then exits.
DESCRIPTION
avahi-publish is a command-line utility from the Avahi project, an open-source implementation of Zeroconf (also known as Bonjour or Rendezvous). It enables users to advertise network services or host addresses on a local network using mDNS (multicast DNS) and DNS-SD (DNS Service Discovery) protocols. This allows other Zeroconf-aware clients to discover these advertised resources without the need for a centralized DNS server. It's often used for temporary announcements, testing, or in scripts where dynamic service advertisement is required, as the publications cease when the command exits unless explicitly daemonized.
The tool acts as a wrapper for two main functionalities: publishing services (similar to avahi-publish-service for advertising services like HTTP, SSH, with their port and optional TXT records) and publishing addresses (similar to avahi-publish-address for associating a hostname with an IP address). Unlike avahi-daemon which provides persistent service publication, avahi-publish offers a more direct, transient method of advertising.
CAVEATS
Unless daemonized with the -d option, published services and addresses are temporary and will cease to be advertised as soon as the avahi-publish command exits. This tool can operate independently of the avahi-daemon, meaning the daemon does not need to be running for avahi-publish to function; it can directly send mDNS packets. However, if the daemon is running, avahi-publish might communicate with it via D-Bus for some operations. Publishing services makes them discoverable to other devices on the local network; ensure any advertised services are intentionally public.
ZEROCONF PRINCIPLES (MDNS/DNS-SD)
avahi-publish operates on the principles of Zeroconf, specifically Multicast DNS (mDNS) and DNS Service Discovery (DNS-SD). mDNS allows hosts to resolve domain names to IP addresses within a small local network without requiring a central DNS server. DNS-SD builds upon mDNS by providing a mechanism to discover available network services (e.g., printers, file shares, web servers) and their details (host, port, TXT records) by querying specific service types (e.g., _printer._tcp). avahi-publish directly broadcasts these mDNS/DNS-SD packets on the local network to announce the specified services or addresses, making them immediately discoverable by other Zeroconf-compatible devices.
COMMON USE CASES
Typical applications for avahi-publish include:
- Temporary Service Advertisement: Quickly making a service (e.g., a local web server running on an uncommon port or a custom application) discoverable for a short period.
- Scripting and Automation: Dynamically advertising services from within scripts, for instance, advertising a development server or a test environment only when it's active.
- Testing and Debugging: Verifying that mDNS/DNS-SD is functioning correctly on a network, or testing how client applications react to specific service advertisements.
- Ad-hoc Network Services: Providing simple service discovery in environments without a central infrastructure like a traditional DNS server, such as peer-to-peer networks or temporary setups.
HISTORY
The Avahi project was initiated around 2004 as a free and open-source implementation of Apple's Bonjour (previously called Rendezvous), a suite of technologies for Zeroconf networking. Developed primarily by Lennart Poettering, Trent Lloyd, and others, Avahi provides a robust framework for mDNS/DNS-SD on Linux and other Unix-like systems. avahi-publish emerged as a fundamental command-line tool within this ecosystem, providing a direct interface for users to advertise their services and hosts, mirroring functionalities found in Apple's dns-sd utility. Its development has been integral to making plug-and-play network service discovery a standard feature on Linux desktop environments and embedded systems.
SEE ALSO
avahi-daemon(8), avahi-browse(1), avahi-resolve(1), mdnsd(8), dns-sd(1)