LinuxCommandLibrary

avahi-publish

Publish network services using Avahi (mDNS/DNS-SD)

SYNOPSIS

avahi-publish [OPTIONS] TYPE NAME [PORT] [TXT...]

PARAMETERS

-h, --help
    Show help options.

-v, --verbose
    Enable verbose mode.

-d, --domain=DOMAIN
    The mDNS domain name to use. Defaults to 'local'.

-s, --subtype=SUBTYPE
    The service subtype to publish.

-t, --terminate
    Terminate after publishing.

TYPE
    The service type (e.g., _http._tcp).

NAME
    The service name that other hosts will see.

PORT
    The TCP or UDP port number the service listens on. Defaults to 0 if not specified.

TXT...
    Zero or more TXT records for the service. TXT records are key=value pairs that provide additional information about the service. These are limited to 255 bytes per record.

DESCRIPTION

The avahi-publish command is a command-line tool used to register mDNS/DNS-SD service records on the local network using the Avahi daemon. This allows services running on a host to be automatically discovered by other hosts on the same network using Multicast DNS (mDNS) and DNS Service Discovery (DNS-SD) protocols. It's primarily used for testing and simple service advertisement. It offers a straightforward way to broadcast service information, such as the service name, port number, and service type (e.g., HTTP, SSH), without requiring complex configuration files. Its advantage lies in its simplicity for ad-hoc service publishing and testing mDNS setups. However, due to its command-line nature, its suitable mainly for development, demonstration, or environments where persistence isn't critical. Real-world services generally use configuration files and systemd integration to ensure reliable and automatic service advertisement. Note that `avahi-publish` relies on the Avahi daemon to be running.

CAVEATS

The service is only advertised as long as the command is running. When the command terminates, the service record is withdrawn. Ensure the Avahi daemon is running before using this command. It's not suitable for production environments requiring persistent service advertisements.

EXAMPLES

  • To publish an HTTP service named 'My Web Server' on port 80:
    avahi-publish _http._tcp "My Web Server" 80
  • To publish an SSH service with TXT record:
    avahi-publish _ssh._tcp "My SSH Server" 22 "version=1.0"
  • To specify the domain:
    avahi-publish -d example.com _http._tcp "My Web Server" 80

SECURITY CONSIDERATIONS

mDNS is unencrypted and relies on local network trust. Do not publish sensitive information in TXT records. Also, be aware that anyone on the network can potentially discover published services.

TROUBLESHOOTING

If the service isn't being discovered, check if the Avahi daemon is running and if there are any firewall rules blocking mDNS traffic (port 5353). Use avahi-browse to verify if the service is being advertised correctly.

HISTORY

avahi-publish is part of the Avahi project, which was created to implement mDNS/DNS-SD protocols. It was developed to provide a zero-configuration networking solution for Linux and other Unix-like systems. Avahi itself has become a standard component on many Linux distributions for service discovery. avahi-publish has been included with Avahi since its early releases, providing a simple way to manually advertise services via mDNS.

SEE ALSO

Copied to clipboard