Not detecting responses from IPv6 addresses
AlCalzone opened this issue · 3 comments
Repost from watson/bonjour#44 as I think the issue is a better fit here.
I'm trying to detect an IKEA TRADFRI gateway using bonjour without any success. When inspecting the traffic with Wireshark, I do see a response from that gateway but it seems to be the only one using IPv6 addresses. As a result it doesn't show up in the detected services.
Here's the dissected packet from Wireshark:
Frame 5023: 769 bytes on wire (6152 bits), 769 bytes captured (6152 bits) on interface 0
Ethernet II, Src: MurataMa_25:7a:41 (b0:72:bf:25:7a:41), Dst: IPv6mcast_fb (33:33:00:00:00:fb)
Internet Protocol Version 6, Src: 2003:e6:c3f6:f311:b272:bfff:fe25:7a41, Dst: ff02::fb
User Datagram Protocol, Src Port: 5353, Dst Port: 5353
Multicast Domain Name System (response)
Transaction ID: 0x0000
Flags: 0x8400 Standard query response, No error
Questions: 0
Answer RRs: 8
Authority RRs: 0
Additional RRs: 2
Answers
_services._dns-sd._udp.local: type PTR, class IN, _coap._udp.local
_coap._udp.local: type PTR, class IN, gw-b072bf257a41._coap._udp.local
gw-b072bf257a41._coap._udp.local: type TXT, class IN, cache flush
gw-b072bf257a41._coap._udp.local: type SRV, class IN, cache flush, priority 0, weight 0, port 5684, target TRADFRI-Gateway-b072bf257a41.local
_services._dns-sd._udp.local: type PTR, class IN, _hap._tcp.local
_hap._tcp.local: type PTR, class IN, TRADFRI gateway._hap._tcp.local
TRADFRI gateway._hap._tcp.local: type TXT, class IN, cache flush
TRADFRI gateway._hap._tcp.local: type SRV, class IN, cache flush, priority 0, weight 0, port 80, target TRADFRI-Gateway-b072bf257a41.local
Additional records
TRADFRI-Gateway-b072bf257a41.local: type A, class IN, cache flush, addr 192.168.2.102
TRADFRI-Gateway-b072bf257a41.local: type AAAA, class IN, cache flush, addr fe80::b272:bfff:fe25:7a41
I believe the issue comes from the server socket only listening on IPv4. Since the gateway only sends messages to the IPv6 address, they'll get lost. It should be possible to listen to both addresses, using code similar to this:
var d = require("dgram");
var s = d.createSocket({type:"udp4",reuseAddr:true});
s.bind(9000);
var s6 = d.createSocket({type:"udp6",reuseAddr:true});
s6.bind(9000);
I'll be happy to prepare a PR if that's something you want to support.
Hey @AlCalzone, not sure if you tried something like this; It's working for me.
var opts = {
interface: '::%enp0s5',
type: 'udp6',
ip: 'ff02::1:3'
}
var mdns = require('multicast-dns')(opts)
mdns.on('query', function (query) {
if (query.questions[0].name === 'brunhilde.local')
console.log('query', query)
})
( not with the ikea thing, just another node process sending a query using similar options)
Thanks for the response. I might have to skip the bonjour module then but its worth a try.
Didn't get this to work with multicast-dns
, but with mdns-server. Not sure which subtle difference makes that possible, but mdns-server
is working flawlessly in mixed networks.