← 返回命令列表

Linux command

avahi-publish 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Register

avahi-publish -s "[service_name]" [service_type] [port]

Register

avahi-publish -s "[service_name]" _http._tcp [port] "path=/index.html"

Register

avahi-publish -a [hostname] [ip_address]

Register

avahi-publish -s -v "[service_name]" [service_type] [port]

Register

avahi-publish -s --domain=[domain] "[service_name]" [service_type] [port]

Register

avahi-publish -s --subtype=[subtype] "[service_name]" [service_type] [port]

说明

avahi-publish is a command-line utility for registering mDNS/DNS-SD services or hostname-to-address mappings through the Avahi daemon. It enables network service advertisement and hostname resolution on local networks using mDNS (Multicast DNS) and DNS-SD (DNS Service Discovery) protocols. The tool operates in two primary modes: > Service Registration Mode (-s): Registers a network service by specifying a DNS-SD service name (e.g., "Web Server"), a service type (e.g., _http._tcp), and an IP port number. Optional TXT record strings can be appended to provide additional service metadata like path, version, or configuration parameters. > Address/Hostname Registration Mode (-a): Registers a mapping between a fully qualified hostname and an IPv4 or IPv6 address, enabling name resolution via mDNS. When started, avahi-publish connects to the Avahi daemon and maintains the registration until the process is terminated. The registration is automatically withdrawn when the process exits. Service types follow the DNS-SD naming convention: _service._proto where service identifies the application protocol (http, ssh, ftp) and proto is either _tcp or _udp. For example, _http._tcp for HTTP services or _ssh._tcp for SSH. By default, services are published in the .local domain, but this can be changed using the --domain option. The tool also supports service subtypes via --subtype, allowing additional service categorization.

参数

-s, --service
Register a service (requires name, service type, and port)
-a, --address
Register hostname-to-address mapping
-v, --verbose
Enable verbose output with detailed information
-H, --host=_HOSTNAME_
Specify remote host name for the service
-d, --domain=_DOMAIN_
Publish in specified domain (default: .local)
--subtype=_SUBTYPE_
Add subtype registration to the primary service type (repeatable)
-R, --no-reverse
Skip publishing reverse (address-to-name) entry
-f, --no-fail
Continue and reconnect if daemon becomes unavailable
-h, --help
Display help information
-V, --version
Show version information

FAQ

What is the avahi-publish command used for?

avahi-publish is a command-line utility for registering mDNS/DNS-SD services or hostname-to-address mappings through the Avahi daemon. It enables network service advertisement and hostname resolution on local networks using mDNS (Multicast DNS) and DNS-SD (DNS Service Discovery) protocols. The tool operates in two primary modes: > Service Registration Mode (-s): Registers a network service by specifying a DNS-SD service name (e.g., "Web Server"), a service type (e.g., _http._tcp), and an IP port number. Optional TXT record strings can be appended to provide additional service metadata like path, version, or configuration parameters. > Address/Hostname Registration Mode (-a): Registers a mapping between a fully qualified hostname and an IPv4 or IPv6 address, enabling name resolution via mDNS. When started, avahi-publish connects to the Avahi daemon and maintains the registration until the process is terminated. The registration is automatically withdrawn when the process exits. Service types follow the DNS-SD naming convention: _service._proto where service identifies the application protocol (http, ssh, ftp) and proto is either _tcp or _udp. For example, _http._tcp for HTTP services or _ssh._tcp for SSH. By default, services are published in the .local domain, but this can be changed using the --domain option. The tool also supports service subtypes via --subtype, allowing additional service categorization.

How do I run a basic avahi-publish example?

Run `avahi-publish -s "[service_name]" [service_type] [port]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s, --service do in avahi-publish?

Register a service (requires name, service type, and port)