brutella / dnssd

This library implements Multicast DNS (mDNS) and DNS-Based Service Discovery (DNS-SD) for Zero Configuration Networking in Go.
MIT License
207 stars 33 forks source link

dnssd on Linux not responding to multicast DNS lookups #4

Closed jamessanford closed 6 years ago

jamessanford commented 6 years ago
linux% go get github.com/brutella/hklight
linux% $GOPATH/bin/hklight

The service appears, but after two minutes, is removed:

osx% dns-sd -B _hap._tcp
Browsing for _hap._tcp
DATE: ---Wed 22 Nov 2017---
21:57:49.094  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
21:57:49.095  Add        2   5 local.               _hap._tcp.           Personal_Light_Bulb
21:59:47.216  Rmv        0   5 local.               _hap._tcp.           Personal_Light_Bulb

If you run tcpdump and run browse.go, you can see lookup packets but no answer.

osx% tcpdump -n -p -v -i en4 port 5353

osx% go get -d github.com/brutella/dnssd
osx% cd $GOPATH/src/github.com/brutella/dnssd/_cmd
osx% go run browse.go
tcpdump: listening on en4, link-type EN10MB (Ethernet), capture size 262144 bytes
22:00:27.957981 IP (tos 0x0, ttl 1, id 7291, offset 0, flags [none], proto UDP (17), length 61)
    192.168.1.40.5353 > 224.0.0.251.5353: 0 PTR (QM)? _hap._tcp.local. (33)
jamessanford commented 6 years ago

With the above PR applied, it works as expected on Linux, and it continues to work on OSX.

linux% ./hklight
osx% cd $GOPATH/src/github.com/brutella/dnssd/_cmd
osx% go run browse.go
Browsing for _hap._tcp.local.
DATE: –––Wed Nov 22 2017–––
22:28:00.852  ...STARTING...
Timestamp   A/R Domain  Service Type    Service Name
22:28:00.973    Add local.  _hap._tcp.  Personal_Light_Bulb
osx% tcpdump -n -p -v -i en4 port 5353
tcpdump: listening on en4, link-type EN10MB (Ethernet), capture size 262144 bytes
22:28:00.852629 IP (tos 0x0, ttl 1, id 26358, offset 0, flags [none], proto UDP (17), length 61)
    192.168.1.40.5353 > 224.0.0.251.5353: 0 PTR (QM)? _hap._tcp.local. (33)
22:28:00.972778 IP (tos 0x0, ttl 1, id 36682, offset 0, flags [DF], proto UDP (17), length 414)
    192.168.1.20.5353 > 224.0.0.251.5353: 0*- [0q] 1/0/4 _hap._tcp.local. PTR Personal_Light_Bulb._hap._tcp.local. (386)
22:28:00.972827 IP6 (flowlabel 0x9cedb, hlim 1, next-header UDP (17) payload length: 394) fe80::dfff:7fff:aaaa:aaaa.5353 > ff02::fb.5353: [udp sum ok] 0*- [0q] 1/0/4 _hap._tcp.local. PTR Personal_Light_Bulb._hap._tcp.local. (386)