Linux command
avahi-publish-service 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Publish
avahi-publish-service [MyService] [_http._tcp] [80]
Example
avahi-publish-service [MyService] [_http._tcp] [80] ["path=/api"]
Example
avahi-publish-service -H [myhost.local] [MyService] [_http._tcp] [80]
Example
avahi-publish-service --subtype=[_printer._sub._http._tcp] [MyPrinter] [_http._tcp] [631]
说明
avahi-publish-service registers a mDNS/DNS-SD service on the local network via the Avahi daemon. It allows services to be discovered by other devices using Avahi or Bonjour-compatible service discovery. This command is equivalent to avahi-publish -s and provides a convenient shortcut specifically for service registration. The tool requires a service name, a DNS-SD service type (e.g., _http._tcp), and a port number. Optional TXT record strings can provide additional metadata about the service. Service subtypes can be registered for more specific categorization. The registration persists only while the process is running. When terminated, the service advertisement is automatically withdrawn from the network.
参数
- -H, --host=_HOSTNAME_
- Specify a host name for the service if it does not reside on the local host. Must be fully qualified and resolvable via mDNS or unicast DNS.
- -d, --domain=_DOMAIN_
- Publish in the specified domain. If omitted, the Avahi daemon publishes in its default domain (usually .local).
- --subtype=_SUBTYPE_
- Register the service with an additional subtype. May be passed multiple times.
- -f, --no-fail
- Don't fail if the daemon is not running. Wait for it to appear and reconnect if it disconnects.
- -v, --verbose
- Enable verbose mode.
- -V, --version
- Show version information.
- -h, --help
- Show help.
FAQ
What is the avahi-publish-service command used for?
avahi-publish-service registers a mDNS/DNS-SD service on the local network via the Avahi daemon. It allows services to be discovered by other devices using Avahi or Bonjour-compatible service discovery. This command is equivalent to avahi-publish -s and provides a convenient shortcut specifically for service registration. The tool requires a service name, a DNS-SD service type (e.g., _http._tcp), and a port number. Optional TXT record strings can provide additional metadata about the service. Service subtypes can be registered for more specific categorization. The registration persists only while the process is running. When terminated, the service advertisement is automatically withdrawn from the network.
How do I run a basic avahi-publish-service example?
Run `avahi-publish-service [MyService] [_http._tcp] [80]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -H, --host=_HOSTNAME_ do in avahi-publish-service?
Specify a host name for the service if it does not reside on the local host. Must be fully qualified and resolvable via mDNS or unicast DNS.