0

I successfully registered a service in my App which I can see on my Generic Linux device using the command line tool avahi-browse. What I wonder is the following: why does avahi-browse does show the IPv4 address of my Android but not the IPv6 (link local) address? Both sections are printed on the screen.

How do I make the service discovery promote the IPv6 address. Please see my code snippet below:

try {
    val serviceInfo = NsdServiceInfo().apply {
        // host = InetAddress.getByName("fe80::1234/64") // TODO: This fails
        serviceName = TAG
        serviceType = mServiceType
        setPort(port)
    }
...
DennisS
  • 3
  • 3
  • You need to include the Zone ID with Link-Local IPv6 addresses. – Ron Maupin Oct 07 '20 at 18:18
  • Okay... can you elaborate that? I added the zone ID and that did the trick... somehow. "avahi-browse" still shows the IPv4 address for both sections. "avahi-discover" shows the "public" IPv6 address instead of the local link address I added to the function call... the whole behaviour seems quite strange for me. – DennisS Oct 07 '20 at 18:52
  • IPv6 link-local addresses are all in the same network range, so when you refer to a link-local address, you must include the Zone ID to distinguish which link-local network. Remember that hosts can have multiple interfaces, and every IPv6 interface will have an address in the same link-local network range, but a different link-local network. – Ron Maupin Oct 07 '20 at 19:06
  • Thanks again.. I changed this but still, the Android Network Service Discovery propagates the "public" IPv6 address and not the link-local address I pass to the "getByName()" method. Although it is the correct WiFi interface. – DennisS Oct 08 '20 at 04:53
  • I am looking something similar, NsdService discovers both IPv4 & IPv6 addresses for the service tag, but finally gives IPv4 as result. Is it possible to share the changes in above snippet that made it work for you. It will be helpful. – Suyambu Apr 13 '22 at 12:04

0 Answers0