avahi-publish-service
Publish network services using Avahi
SYNOPSIS
avahi-publish-service [options] TYPE NAME PORT [TXT-RECORD ...]
PARAMETERS
-v, --verbose
Enable more verbose output
-f, --no-fail
Do not fail immediately; retry for 30 seconds before exiting non-zero
-D, --no-drop
Do not drop root privileges after binding (root only)
-d DOMAIN, --domain=DOMAIN
Domain to publish on (default: local)
-H HOSTNAME, --host=HOSTNAME
Hostname to publish as (default: local hostname)
--help
Show help message
--version
Show version information
DESCRIPTION
avahi-publish-service is a utility from the Avahi package, Linux's implementation of Zeroconf networking using multicast DNS (mDNS) and DNS Service Discovery (DNS-SD). It advertises local network services like web servers, SSH, printers, or custom protocols, making them discoverable without a DNS server or manual configuration.
Users specify the service type (e.g., _http._tcp), a human-readable name, the TCP/UDP port, and optional TXT records for metadata (e.g., path=/foo). The tool connects to the running avahi-daemon, registers the service, and continuously announces it via multicast to the .local domain or specified domain.
This enables seamless service discovery for applications supporting mDNS, such as browsers, file managers, or IoT devices. Ideal for home networks, development, or ad-hoc setups. The command daemonizes by default, rebroadcasting periodically, and can be stopped with Ctrl+C. It handles hostname resolution automatically but allows overrides.
CAVEATS
Requires avahi-daemon to be running. Services are visible network-wide on LAN. Drops privileges to 'avahi' user by default unless -D. Exits non-zero only after retries unless -f. No built-in unpublishing; kill process to stop.
EXAMPLES
avahi-publish-service _http._tcp MyWeb 8080 path=/docs
avahi-publish-service -v _ssh._tcp myserver 22 user=admin
avahi-publish-service _printer._tcp HPPrinter 9100 txtvers=1 qtotal=1
TXT RECORDS
Optional key=value pairs after port for metadata (e.g., rp=/printer, note=Hello). Multiline or quoted values unsupported; simple strings only.
HISTORY
Introduced in early Avahi releases (~2006) by Lennart Poettering and Trent Waddington as part of the Avahi Zeroconf project, mirroring Apple's Bonjour. Actively maintained in most Linux distros; evolves with mDNS standards.
SEE ALSO
avahi-daemon(8), avahi-browse(1), avahi-resolve(1), avahi-discover(1)


