使用Avahi可以使用临时注册创建,avahi-publish并且可以通过编写静态服务文件来创建持久注册.有关man 1 avahi-publish前者的更多信息,请参见man 5 avahi.service后者.
使用Bonjour,dns-sd工具可用于代理注册服务:
dns-sd -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...]
如果您代理注册的服务已经具有单播DNS主机名,则此类功能将起作用:
$ dns-sd -P Google _http._tcp local 80 google.com google.com path=/
Registering Service Google._http._tcp.local host google.com port 80 TXT path=/
4:23:00.928 Got a reply for service Google._http._tcp.local.: Name now registered and active
^C
Run Code Online (Sandbox Code Playgroud)
如果它没有主机名,则应该为主机使用唯一名称:
$ dns-sd -P Google _http._tcp local 80 google.local 74.125.237.144 path=/
Registering Service Google._http._tcp.local host google.local port 80 TXT path=/
4:16:48.208 Got a reply for record google.local: Name now registered and active
4:16:48.208 Got a reply for service Google._http._tcp.local.: Name now registered and active
^C
Run Code Online (Sandbox Code Playgroud)