6

I know that iOS's Bonjour implementation (NSNetService, NSNetServiceBrowser) work out of the box on local networks.

The documentation says it is possible to set up a Bonjour DNS server to allow connecting users over the internet, so my questions are:

  1. What is the Bonjour DNS server interface? is there a sample I can start from?
  2. Does the DNS Server responsible for the initial hand-shaking\connection of the peers and the rest (send\rec data) will be directly between the peers?
  3. Does the DNS Server provide a NAT hole-punching mechanism?

Thanks!

Andrew
  • 8,363
  • 8
  • 43
  • 71
sternr
  • 6,216
  • 9
  • 39
  • 63

1 Answers1

4

Bonjour local service discoveryis based on "multicast DNS". whenever some client wants to find out anything about the network or services on the network it uses the multicast address 224.0.0.251, meaning only clients within that multicast group can use bonjour together. the 244.0.0/24 IP-Address space is defined as "Local Network Control Block" by RFC5771 and will not be forwarded out of your local network.

BUT really, Bonjour is just a DNS-based method - you can tell NSServiceBrowser to search in a non-local domain, which just requires the DNS server to respond to specific requests (as described in Manually Adding DNS-SD Service Discovery Records to an Existing Name Server) This allows service discovery over the internet and even service registration if you get DNS Update working (Setting up a Bonjour Name Server), but nothing more - you have to care about hole-punching yourself.

So get yourself a BIND-server and start trying ;)

Martin Ullrich
  • 94,744
  • 25
  • 252
  • 217
  • Thanks for the reply!, is there no over the internet peer-to-peer framework for iOS? – sternr Jun 05 '11 at 10:47
  • at least i don't know any.. if you want to code that yourself, you have to go deep into the frameworks. if the devices you want to connect are near each other, you could use bump's [API](http://bu.mp/files/Documentation/intro.html#getting-started) to connect devices and transfer data over any network with "just a bump".. – Martin Ullrich Jun 05 '11 at 20:35
  • The comment about hole-punching is incorrect. Bonjour will only register a service in a wide-area zone if the machine has a public address or a port-forward can be negotiated via NAT-PMP or uPNP. – andrewtj Jun 20 '11 at 08:12
  • 1
    I just did a quick test: using the C DNS Service Discovery API to register in a domain not configured on my OS X system resulted in Bonjour setting up a port forward and attempting to add the records in that domain. This failed as the zone in question requires updates to have TSIGs. Therefore I'd say that as long as you're okay with allowing open updates (because there's no way to set the TSIG credentials on iOS), it should work fine. Feel free to drop me an email if you have any questions. – andrewtj Jun 20 '11 at 08:28