5

I have a service on another remote system which is on another physical network and its multicast packages don't get to my local system, thus I don't see its DNS-SD published services.

I there a way I can manually register it on my local machine so that applications which only show DNS-SD discovered services show it?

Jake
  • 261
  • 1
  • 17
Albert
  • 65,406
  • 61
  • 242
  • 386

2 Answers2

9

With Avahi temporary registrations can be created using avahi-publish and persistent ones can be created by writing a static service file. See man 1 avahi-publish for more on the former and man 5 avahi.service for more on the later.

With Bonjour the dns-sd tool can be used to proxy register a service:

dns-sd -P <Name> <Type> <Domain> <Port> <Host> <IP> [<TXT>...]

If the service you're proxy registering already has a unicast DNS hostname something like this will work:

$ 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

If it doesn't have a hostname a unique name should be used for the host:

$ 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
andrewtj
  • 326
  • 1
  • 4
  • I'm on a Mac, I have `dns-sd` here. And in its man-page, I don't see a way to do what I want. – Albert Dec 14 '11 at 15:05
  • I assumed you were using Avahi as the question is tagged Avahi but not mDNSResponder or Bonjour. I've updated my answer with example usage of the dns-sd tool. – andrewtj Dec 15 '11 at 04:21
2

This is just what I was looking for. I wanted to make a service housed on a non-OS X system visible from outside the home network. Elsewhere on here, I found out how to use scutil to find out my Back to My Mac network:

echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p' 

So I can take that and use it to populate this:

BTMM=`echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'`

dns-sd -P <advertised host name> _ssh._tcp ${BTMM} 22 <real host name> <real IP address—could be a hostname if it resolves> path=/

The beauty of this is that I don't have to remember to do anything before I leave the house, as long as some variant of ZeroConf is running. I can advertise the remote service from wherever I am, use it, then take down the advertisement. So I run the commands and then look in my Shell -> New Remote Command dialog and there it is. I can then copy files to and fro, run commands, access the home network, all as if I was there.

laalto
  • 150,114
  • 66
  • 286
  • 303
paulbeard
  • 21
  • 1
  • This is wicked cool! There is a nice short explanation about the magic behind this [here](https://webdiary.com/tag/members-btmm-icloud-com/). It’s a pity that _iTunes_ does not pick `_daap._tcp.` from BTMM Bonjour domain. – Mr. Tao Apr 13 '18 at 19:00