dns-sd:如何手动注册远程服务

Alb*_*ert 4 mdns bonjour avahi dns-sd

我在另一个物理网络上的另一个远程系统上有一个服务,它的多播包没有到我的本地系统,因此我看不到它的DNS-SD发布服务.

我有办法在本地机器上手动注册它,以便只显示DNS-SD发现服务的应用程序显示它吗?

and*_*wtj 7

使用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)