avahi / avahi

Avahi - Service Discovery for Linux using mDNS/DNS-SD -- compatible with Bonjour
http://www.avahi.org
GNU Lesser General Public License v2.1
1.18k stars 328 forks source link

Hosts are no longer discovered #560

Open lliendo opened 7 months ago

lliendo commented 7 months ago

Hi there,

I'm opening this issue because I honestly don't know if I'm facing a bug, an inherently mis-configuration, bad luck or some cosmic rays ruining my setup. Here's the thing. Yesterday late at night I configured avahi (along with nsswitch) in Ubuntu and two other FreeBSD boxes. Everything was working just fine, when running avahi-browse --all --resolve --ignore-local --terminate I was able to see all my configured hosts from all machines, even from Termux in a mobile phone.

I'm primarily interested in just getting a list of available hosts in my local network, so I was actually satisfied with things working. I went to bed happily. Today after finishing my day I grabbed these hosts and for apparently no reason I simply can't see those hosts anymore. While yesterday a ping redstar.local worked just fine now the host is unknown. Nothing. Nada. When running avahi-browse --all --resolve --ignore-local --terminateall that I see is this (from any of my hosts in my network):

Server version: avahi 0.7; Host name: zenbook.local
E Ifce Prot Name                                          Type                 Domain
: Cache exhausted
: All for now

Maybe is worth mentioning that I'm using my mobile phone as a hotspot for my local network and yesterday went out of battery (late at night), but I can't possibly see this as the source of the problem. I do not see any errors anywhere, simply hosts are no longer discovered at all. My nsswitch.conf config is as follows:

On my Linux machine: hosts: files mdns4_minimal [NOTFOUND=return] dns (Running avahi-daemon v0.7). On my FreeBSD machines (2 of them): hosts: files mdns4_minimal mdns4 [NOTFOUND=return] dns (Running avahi-daemon 0.8)

Does anyone have a clue as to why a working setup would randomly stop working? After realizing avahi stopped resolving hostnames, I played a bit with the configuration from /etc/avahi/avahi-daemon.conf but none of the changes that I made fixed the problem. What tools do I need to use to somehow track down or understand the source of this issue? Any help really appreciated. I haven't yet rebooted all machines (just the Linux, but the problem persists), so maybe I can still run something to see why this happens, any ideas are welcome.

Thanks, Lucas.

evverx commented 7 months ago

What tools do I need to use to somehow track down or understand the source of this issue?

Could you run Wireshark with the port 5353 filter on redstar.local when another machine tries to resolve that name with avahi-resolve -n redstar.local? It should help to figure out whether mDNS packets with the queries reach that machine at all. If they do and avahi doesn't reply it would make sense to look at the logs to see what avahi registers and where.

Joining mDNS multicast group on interface ...
Registering new address record for ...
Server startup complete. Host name is ...
Leaving mDNS multicast group on interface ...

If mDNS packets don't reach redstar.local it's unlikely to be an avahi issue. It could be that the network interfaces weren't reconfigured when the hotspot went down and up again or something like that.

Either way in its current form it's hard to tell what's going on. It would be great if you could run avahi in debug mode by appending --debug to the command line on at least two machines and run Wireshark on those machines when one of them tries to resolve the host name of the other machine and paste all that here.

lliendo commented 7 months ago

@evverx First of all, thanks for coming back on a weekend. I run what you suggested but with tcpdump. On redstar (running FreeBSD) I run the following command: tcpdump -i wlan0 udp port 5353 -XAvvv. On my Linux box I triggered avahi-resolve -n redstar.local as suggested. Then on the Linux machine I got:

lucas@zenbook:~$ avahi-resolve -n redstar.local
Failed to resolve host name 'redstar.local': Timeout reached

On the FreeBSD box there seems to be some activity after running the above command:

17:25:58.071616 IP6 (flowlabel 0x9eb83, hlim 255, next-header UDP (17) payload length: 45) fe80::cf4e:711d:223f:7337.mdns > ff02::fb.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  6009 eb83 002d 11ff fe80 0000 0000 0000  `....-..........
    0x0010:  cf4e 711d 223f 7337 ff02 0000 0000 0000  .Nq."?s7........
    0x0020:  0000 0000 0000 00fb 14e9 14e9 002d bda5  .............-..
    0x0030:  0000 0000 0002 0000 0000 0000 0772 6564  .............red
    0x0040:  7374 6172 056c 6f63 616c 0000 0100 01c0  star.local......
    0x0050:  0c00 1c00 01                             .....
17:25:58.072839 IP (tos 0x0, ttl 255, id 30843, offset 0, flags [DF], proto UDP (17), length 65)
    192.168.43.19.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  4500 0041 787b 4000 ff11 3679 c0a8 2b13  E..Ax{@...6y..+.
    0x0010:  e000 00fb 14e9 14e9 002d c54f 0000 0000  .........-.O....
    0x0020:  0002 0000 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  056c 6f63 616c 0000 0100 01c0 0c00 1c00  .local..........
    0x0040:  01                                       .
17:25:59.072854 IP6 (flowlabel 0x9eb83, hlim 255, next-header UDP (17) payload length: 45) fe80::cf4e:711d:223f:7337.mdns > ff02::fb.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  6009 eb83 002d 11ff fe80 0000 0000 0000  `....-..........
    0x0010:  cf4e 711d 223f 7337 ff02 0000 0000 0000  .Nq."?s7........
    0x0020:  0000 0000 0000 00fb 14e9 14e9 002d bda5  .............-..
    0x0030:  0000 0000 0002 0000 0000 0000 0772 6564  .............red
    0x0040:  7374 6172 056c 6f63 616c 0000 0100 01c0  star.local......
    0x0050:  0c00 1c00 01                             .....
17:25:59.073961 IP (tos 0x0, ttl 255, id 31084, offset 0, flags [DF], proto UDP (17), length 65)
    192.168.43.19.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  4500 0041 796c 4000 ff11 3588 c0a8 2b13  E..Ayl@...5...+.
    0x0010:  e000 00fb 14e9 14e9 002d c54f 0000 0000  .........-.O....
    0x0020:  0002 0000 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  056c 6f63 616c 0000 0100 01c0 0c00 1c00  .local..........
    0x0040:  01                                       .
17:26:01.073717 IP6 (flowlabel 0x9eb83, hlim 255, next-header UDP (17) payload length: 45) fe80::cf4e:711d:223f:7337.mdns > ff02::fb.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  6009 eb83 002d 11ff fe80 0000 0000 0000  `....-..........
    0x0010:  cf4e 711d 223f 7337 ff02 0000 0000 0000  .Nq."?s7........
    0x0020:  0000 0000 0000 00fb 14e9 14e9 002d bda5  .............-..
    0x0030:  0000 0000 0002 0000 0000 0000 0772 6564  .............red
    0x0040:  7374 6172 056c 6f63 616c 0000 0100 01c0  star.local......
    0x0050:  0c00 1c00 01                             .....
17:26:01.074949 IP (tos 0x0, ttl 255, id 31213, offset 0, flags [DF], proto UDP (17), length 65)
    192.168.43.19.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] A (QM)? redstar.local. AAAA (QM)? redstar.local. (37)
    0x0000:  4500 0041 79ed 4000 ff11 3507 c0a8 2b13  E..Ay.@...5...+.
    0x0010:  e000 00fb 14e9 14e9 002d c54f 0000 0000  .........-.O....
    0x0020:  0002 0000 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  056c 6f63 616c 0000 0100 01c0 0c00 1c00  .local..........
    0x0040:  01

Does this look reasonable?

Once again, thanks for your time!

lliendo commented 7 months ago

Ok, this is weird. I was just about to try what you also suggested: run avahi in debug mode. So I did it and just after that (by running avahi-daemon --debug on FreeBSD, my linux box started to see again redstar.local. No interfaces were restarted. I can see (as I left tcpdump running) some flushing of the cache (can that be the issue or something related to it?). Here the output that I grabbed:

17:36:13.951208 IP (tos 0x0, ttl 255, id 34181, offset 0, flags [none], proto UDP (17), length 121)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [2n] ANY (QM)? 45.43.168.192.in-addr.arpa. ANY (QM)? redstar.local. ns: redstar.local. [2m] A 192.168.43.45, 45.43.168.192.in-addr.arpa. [2m] PTR redstar.local. (93)
    0x0000:  4500 0079 8585 0000 ff11 691d c0a8 2b2d  E..y......i...+-
    0x0010:  e000 00fb 14e9 14e9 0065 b9e0 0000 0000  .........e......
    0x0020:  0002 0000 0002 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 00ff 0001 0772 6564 7374 6172  rpa......redstar
    0x0050:  056c 6f63 616c 0000 ff00 01c0 2c00 0100  .local......,...
    0x0060:  0100 0000 7800 04c0 a82b 2dc0 0c00 0c00  ....x....+-.....
    0x0070:  0100 0000 7800 02c0 2c                   ....x...,
17:36:14.150000 IP (tos 0x0, ttl 255, id 34183, offset 0, flags [none], proto UDP (17), length 72)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 PTR (QM)? 45.43.168.192.in-addr.arpa. (44)
    0x0000:  4500 0048 8587 0000 ff11 694c c0a8 2b2d  E..H......iL..+-
    0x0010:  e000 00fb 14e9 14e9 0034 1460 0000 0000  .........4.`....
    0x0020:  0001 0000 0000 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 000c 0001                      rpa.....
17:36:14.202967 IP (tos 0x0, ttl 255, id 34185, offset 0, flags [none], proto UDP (17), length 121)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [2n] ANY (QM)? 45.43.168.192.in-addr.arpa. ANY (QM)? redstar.local. ns: redstar.local. [2m] A 192.168.43.45, 45.43.168.192.in-addr.arpa. [2m] PTR redstar.local. (93)
    0x0000:  4500 0079 8589 0000 ff11 6919 c0a8 2b2d  E..y......i...+-
    0x0010:  e000 00fb 14e9 14e9 0065 b9e0 0000 0000  .........e......
    0x0020:  0002 0000 0002 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 00ff 0001 0772 6564 7374 6172  rpa......redstar
    0x0050:  056c 6f63 616c 0000 ff00 01c0 2c00 0100  .local......,...
    0x0060:  0100 0000 7800 04c0 a82b 2dc0 0c00 0c00  ....x....+-.....
    0x0070:  0100 0000 7800 02c0 2c                   ....x...,
17:36:14.454963 IP (tos 0x0, ttl 255, id 34187, offset 0, flags [none], proto UDP (17), length 121)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [2n] ANY (QM)? 45.43.168.192.in-addr.arpa. ANY (QM)? redstar.local. ns: redstar.local. [2m] A 192.168.43.45, 45.43.168.192.in-addr.arpa. [2m] PTR redstar.local. (93)
    0x0000:  4500 0079 858b 0000 ff11 6917 c0a8 2b2d  E..y......i...+-
    0x0010:  e000 00fb 14e9 14e9 0065 b9e0 0000 0000  .........e......
    0x0020:  0002 0000 0002 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 00ff 0001 0772 6564 7374 6172  rpa......redstar
    0x0050:  056c 6f63 616c 0000 ff00 01c0 2c00 0100  .local......,...
    0x0060:  0100 0000 7800 04c0 a82b 2dc0 0c00 0c00  ....x....+-.....
    0x0070:  0100 0000 7800 02c0 2c                   ....x...,
17:36:14.656850 IP (tos 0x0, ttl 255, id 34189, offset 0, flags [none], proto UDP (17), length 109)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 2/0/0 45.43.168.192.in-addr.arpa. (Cache flush) [2m] PTR redstar.local., redstar.local. (Cache flush) [2m] A 192.168.43.45 (81)
    0x0000:  4500 006d 858d 0000 ff11 6921 c0a8 2b2d  E..m......i!..+-
    0x0010:  e000 00fb 14e9 14e9 0059 7067 0000 8400  .........Ypg....
    0x0020:  0000 0002 0000 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 000c 8001 0000 0078 000f 0772  rpa........x...r
    0x0050:  6564 7374 6172 056c 6f63 616c 00c0 3200  edstar.local..2.
    0x0060:  0180 0100 0000 7800 04c0 a82b 2d         ......x....+-
17:36:14.881108 IP (tos 0x0, ttl 255, id 34191, offset 0, flags [none], proto UDP (17), length 167)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [4n] ANY (QM)? redstar._ssh._tcp.local. ANY (QM)? redstar._sftp-ssh._tcp.local. ns: redstar._sftp-ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._sftp-ssh._tcp.local. [1h15m] TXT "", redstar._ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._ssh._tcp.local. [1h15m] TXT "" (139)
    0x0000:  4500 00a7 858f 0000 ff11 68e5 c0a8 2b2d  E.........h...+-
    0x0010:  e000 00fb 14e9 14e9 0093 7c74 0000 0000  ..........|t....
    0x0020:  0002 0000 0004 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 ff00 0107 7265 6473 7461 7209 5f73  ......redstar._s
    0x0050:  6674 702d 7373 68c0 1900 ff00 01c0 2900  ftp-ssh.......).
    0x0060:  2100 0100 0000 7800 1000 0000 0000 1607  !.....x.........
    0x0070:  7265 6473 7461 72c0 1ec0 2900 1000 0100  redstar...).....
    0x0080:  0011 9400 0100 c00c 0021 0001 0000 0078  .........!.....x
    0x0090:  0008 0000 0000 0016 c053 c00c 0010 0001  .........S......
    0x00a0:  0000 1194 0001 00                        .......
17:36:15.133065 IP (tos 0x0, ttl 255, id 34193, offset 0, flags [none], proto UDP (17), length 167)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [4n] ANY (QM)? redstar._ssh._tcp.local. ANY (QM)? redstar._sftp-ssh._tcp.local. ns: redstar._sftp-ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._sftp-ssh._tcp.local. [1h15m] TXT "", redstar._ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._ssh._tcp.local. [1h15m] TXT "" (139)
    0x0000:  4500 00a7 8591 0000 ff11 68e3 c0a8 2b2d  E.........h...+-
    0x0010:  e000 00fb 14e9 14e9 0093 7c74 0000 0000  ..........|t....
    0x0020:  0002 0000 0004 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 ff00 0107 7265 6473 7461 7209 5f73  ......redstar._s
    0x0050:  6674 702d 7373 68c0 1900 ff00 01c0 2900  ftp-ssh.......).
    0x0060:  2100 0100 0000 7800 1000 0000 0000 1607  !.....x.........
    0x0070:  7265 6473 7461 72c0 1ec0 2900 1000 0100  redstar...).....
    0x0080:  0011 9400 0100 c00c 0021 0001 0000 0078  .........!.....x
    0x0090:  0008 0000 0000 0016 c053 c00c 0010 0001  .........S......
    0x00a0:  0000 1194 0001 00                        .......
17:36:15.385040 IP (tos 0x0, ttl 255, id 34195, offset 0, flags [none], proto UDP (17), length 167)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0 [2q] [4n] ANY (QM)? redstar._ssh._tcp.local. ANY (QM)? redstar._sftp-ssh._tcp.local. ns: redstar._sftp-ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._sftp-ssh._tcp.local. [1h15m] TXT "", redstar._ssh._tcp.local. [2m] SRV redstar.local.:22 0 0, redstar._ssh._tcp.local. [1h15m] TXT "" (139)
    0x0000:  4500 00a7 8593 0000 ff11 68e1 c0a8 2b2d  E.........h...+-
    0x0010:  e000 00fb 14e9 14e9 0093 7c74 0000 0000  ..........|t....
    0x0020:  0002 0000 0004 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 ff00 0107 7265 6473 7461 7209 5f73  ......redstar._s
    0x0050:  6674 702d 7373 68c0 1900 ff00 01c0 2900  ftp-ssh.......).
    0x0060:  2100 0100 0000 7800 1000 0000 0000 1607  !.....x.........
    0x0070:  7265 6473 7461 72c0 1ec0 2900 1000 0100  redstar...).....
    0x0080:  0011 9400 0100 c00c 0021 0001 0000 0078  .........!.....x
    0x0090:  0008 0000 0000 0016 c053 c00c 0010 0001  .........S......
    0x00a0:  0000 1194 0001 00                        .......
17:36:15.587864 IP (tos 0x0, ttl 255, id 34198, offset 0, flags [none], proto UDP (17), length 250)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 9/0/0 redstar._ssh._tcp.local. (Cache flush) [1h15m] TXT "", _sftp-ssh._tcp.local. [1h15m] PTR redstar._sftp-ssh._tcp.local., redstar._sftp-ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, redstar.local. (Cache flush) [2m] A 192.168.43.45, redstar._sftp-ssh._tcp.local. (Cache flush) [1h15m] TXT "", _services._dns-sd._udp.local. [1h15m] PTR _sftp-ssh._tcp.local., _ssh._tcp.local. [1h15m] PTR redstar._ssh._tcp.local., redstar._ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, _services._dns-sd._udp.local. [1h15m] PTR _ssh._tcp.local. (222)
    0x0000:  4500 00fa 8596 0000 ff11 688b c0a8 2b2d  E.........h...+-
    0x0010:  e000 00fb 14e9 14e9 00e6 0ec8 0000 8400  ................
    0x0020:  0000 0009 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 1080 0100 0011 9400 0100 095f 7366  ............._sf
    0x0050:  7470 2d73 7368 c019 000c 0001 0000 1194  tp-ssh..........
    0x0060:  000a 0772 6564 7374 6172 c030 c046 0021  ...redstar.0.F.!
    0x0070:  8001 0000 0078 0010 0000 0000 0016 0772  .....x.........r
    0x0080:  6564 7374 6172 c01e c062 0001 8001 0000  edstar...b......
    0x0090:  0078 0004 c0a8 2b2d c046 0010 8001 0000  .x....+-.F......
    0x00a0:  1194 0001 0009 5f73 6572 7669 6365 7307  ......_services.
    0x00b0:  5f64 6e73 2d73 6404 5f75 6470 c01e 000c  _dns-sd._udp....
    0x00c0:  0001 0000 1194 0002 c030 c014 000c 0001  .........0......
    0x00d0:  0000 1194 0002 c00c c00c 0021 8001 0000  ...........!....
    0x00e0:  0078 0008 0000 0000 0016 c062 c089 000c  .x.........b....
    0x00f0:  0001 0000 1194 0002 c014                 ..........
17:36:15.830775 IP (tos 0x0, ttl 255, id 18231, offset 0, flags [none], proto UDP (17), length 93)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 1/0/0 45.43.168.192.in-addr.arpa. (Cache flush) [2m] PTR redstar.local. (65)
    0x0000:  4500 005d 4737 0000 ff11 a787 c0a8 2b2d  E..]G7........+-
    0x0010:  e000 00fb 14e9 14e9 0049 f7b4 0000 8400  .........I......
    0x0020:  0000 0001 0000 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 000c 8001 0000 0078 000f 0772  rpa........x...r
    0x0050:  6564 7374 6172 056c 6f63 616c 00         edstar.local.
17:36:16.762582 IP (tos 0x0, ttl 255, id 64330, offset 0, flags [none], proto UDP (17), length 250)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 9/0/0 redstar._ssh._tcp.local. (Cache flush) [1h15m] TXT "", _sftp-ssh._tcp.local. [1h15m] PTR redstar._sftp-ssh._tcp.local., redstar._sftp-ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, redstar.local. (Cache flush) [2m] A 192.168.43.45, redstar._sftp-ssh._tcp.local. (Cache flush) [1h15m] TXT "", _services._dns-sd._udp.local. [1h15m] PTR _sftp-ssh._tcp.local., _ssh._tcp.local. [1h15m] PTR redstar._ssh._tcp.local., redstar._ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, _services._dns-sd._udp.local. [1h15m] PTR _ssh._tcp.local. (222)
    0x0000:  4500 00fa fb4a 0000 ff11 f2d6 c0a8 2b2d  E....J........+-
    0x0010:  e000 00fb 14e9 14e9 00e6 0ec8 0000 8400  ................
    0x0020:  0000 0009 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 1080 0100 0011 9400 0100 095f 7366  ............._sf
    0x0050:  7470 2d73 7368 c019 000c 0001 0000 1194  tp-ssh..........
    0x0060:  000a 0772 6564 7374 6172 c030 c046 0021  ...redstar.0.F.!
    0x0070:  8001 0000 0078 0010 0000 0000 0016 0772  .....x.........r
    0x0080:  6564 7374 6172 c01e c062 0001 8001 0000  edstar...b......
    0x0090:  0078 0004 c0a8 2b2d c046 0010 8001 0000  .x....+-.F......
    0x00a0:  1194 0001 0009 5f73 6572 7669 6365 7307  ......_services.
    0x00b0:  5f64 6e73 2d73 6404 5f75 6470 c01e 000c  _dns-sd._udp....
    0x00c0:  0001 0000 1194 0002 c030 c014 000c 0001  .........0......
    0x00d0:  0000 1194 0002 c00c c00c 0021 8001 0000  ...........!....
    0x00e0:  0078 0008 0000 0000 0016 c062 c089 000c  .x.........b....
    0x00f0:  0001 0000 1194 0002 c014                 ..........
17:36:18.042363 IP (tos 0x0, ttl 255, id 64331, offset 0, flags [none], proto UDP (17), length 109)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 2/0/0 45.43.168.192.in-addr.arpa. (Cache flush) [2m] PTR redstar.local., redstar.local. (Cache flush) [2m] A 192.168.43.45 (81)
    0x0000:  4500 006d fb4b 0000 ff11 f362 c0a8 2b2d  E..m.K.....b..+-
    0x0010:  e000 00fb 14e9 14e9 0059 7067 0000 8400  .........Ypg....
    0x0020:  0000 0002 0000 0000 0234 3502 3433 0331  .........45.43.1
    0x0030:  3638 0331 3932 0769 6e2d 6164 6472 0461  68.192.in-addr.a
    0x0040:  7270 6100 000c 8001 0000 0078 000f 0772  rpa........x...r
    0x0050:  6564 7374 6172 056c 6f63 616c 00c0 3200  edstar.local..2.
    0x0060:  0180 0100 0000 7800 04c0 a82b 2d         ......x....+-
17:36:18.952520 IP (tos 0x0, ttl 255, id 58399, offset 0, flags [none], proto UDP (17), length 250)
    redstar.local.mdns > 224.0.0.251.mdns: [udp sum ok] 0*- [0q] 9/0/0 redstar._ssh._tcp.local. (Cache flush) [1h15m] TXT "", _sftp-ssh._tcp.local. [1h15m] PTR redstar._sftp-ssh._tcp.local., redstar._sftp-ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, redstar.local. (Cache flush) [2m] A 192.168.43.45, redstar._sftp-ssh._tcp.local. (Cache flush) [1h15m] TXT "", _services._dns-sd._udp.local. [1h15m] PTR _sftp-ssh._tcp.local., _ssh._tcp.local. [1h15m] PTR redstar._ssh._tcp.local., redstar._ssh._tcp.local. (Cache flush) [2m] SRV redstar.local.:22 0 0, _services._dns-sd._udp.local. [1h15m] PTR _ssh._tcp.local. (222)
    0x0000:  4500 00fa e41f 0000 ff11 0a02 c0a8 2b2d  E.............+-
    0x0010:  e000 00fb 14e9 14e9 00e6 0ec8 0000 8400  ................
    0x0020:  0000 0009 0000 0000 0772 6564 7374 6172  .........redstar
    0x0030:  045f 7373 6804 5f74 6370 056c 6f63 616c  ._ssh._tcp.local
    0x0040:  0000 1080 0100 0011 9400 0100 095f 7366  ............._sf
    0x0050:  7470 2d73 7368 c019 000c 0001 0000 1194  tp-ssh..........
    0x0060:  000a 0772 6564 7374 6172 c030 c046 0021  ...redstar.0.F.!
    0x0070:  8001 0000 0078 0010 0000 0000 0016 0772  .....x.........r
    0x0080:  6564 7374 6172 c01e c062 0001 8001 0000  edstar...b......
    0x0090:  0078 0004 c0a8 2b2d c046 0010 8001 0000  .x....+-.F......
    0x00a0:  1194 0001 0009 5f73 6572 7669 6365 7307  ......_services.
    0x00b0:  5f64 6e73 2d73 6404 5f75 6470 c01e 000c  _dns-sd._udp....
    0x00c0:  0001 0000 1194 0002 c030 c014 000c 0001  .........0......
    0x00d0:  0000 1194 0002 c00c c00c 0021 8001 0000  ...........!....
    0x00e0:  0078 0008 0000 0000 0016 c062 c089 000c  .x.........b....
    0x00f0:  0001 0000 1194 0002 c014                 ..........
17:37:21.294224 IP6 (flowlabel 0x9eb83, hlim 255, next-header UDP (17) payload length: 40) fe80::cf4e:711d:223f:7337.mdns > ff02::fb.mdns: [udp sum ok] 0 A (QM)? bluestar.local. (32)
    0x0000:  6009 eb83 0028 11ff fe80 0000 0000 0000  `....(..........
    0x0010:  cf4e 711d 223f 7337 ff02 0000 0000 0000  .Nq."?s7........
    0x0020:  0000 0000 0000 00fb 14e9 14e9 0028 04e5  .............(..
    0x0030:  0000 0000 0001 0000 0000 0000 0862 6c75  .............blu
    0x0040:  6573 7461 7205 6c6f 6361 6c00 0001 0001  estar.local.....
17:37:21.295319 IP (tos 0x0, ttl 255, id 64006, offset 0, flags [DF], proto UDP (17), length 60)
    192.168.43.19.mdns > 224.0.0.251.mdns: [udp sum ok] 0 A (QM)? bluestar.local. (32)
    0x0000:  4500 003c fa06 4000 ff11 b4f2 c0a8 2b13  E..<..@.......+.
    0x0010:  e000 00fb 14e9 14e9 0028 0c8f 0000 0000  .........(......
    0x0020:  0001 0000 0000 0000 0862 6c75 6573 7461  .........bluesta
    0x0030:  7205 6c6f 6361 6c00 0001 0001            r.local.....
17:37:22.295952 IP6 (flowlabel 0x9eb83, hlim 255, next-header UDP (17) payload length: 40) fe80::cf4e:711d:223f:7337.mdns > ff02::fb.mdns: [udp sum ok] 0 A (QM)? bluestar.local. (32)
    0x0000:  6009 eb83 0028 11ff fe80 0000 0000 0000  `....(..........
    0x0010:  cf4e 711d 223f 7337 ff02 0000 0000 0000  .Nq."?s7........
    0x0020:  0000 0000 0000 00fb 14e9 14e9 0028 04e5  .............(..
    0x0030:  0000 0000 0001 0000 0000 0000 0862 6c75  .............blu
    0x0040:  6573 7461 7205 6c6f 6361 6c00 0001 0001  estar.local.....
17:37:22.297063 IP (tos 0x0, ttl 255, id 64182, offset 0, flags [DF], proto UDP (17), length 60)
    192.168.43.19.mdns > 224.0.0.251.mdns: [udp sum ok] 0 A (QM)? bluestar.local. (32)
    0x0000:  4500 003c fab6 4000 ff11 b442 c0a8 2b13  E..<..@....B..+.
    0x0010:  e000 00fb 14e9 14e9 0028 0c8f 0000 0000  .........(......
    0x0020:  0001 0000 0000 0000 0862 6c75 6573 7461  .........bluesta
    0x0030:  7205 6c6f 6361 6c00 0001 0001            r.local.....

Also in this dump note that there's a bluestar.local host (that's the other FreeBSD box), but pinging it from Linux is not reachable! It looks like if I login to that host and perform a restart of avahi it will be visible... I just won't restart it yet if we can get more information about this problem... Maybe you have some other commands for me to try...

Here's the output of avahi-daemon --debug (FreeBSD box redstar.local):

[root@redstar ~]# avahi-daemon --debug
Found user 'avahi' (UID 558) and group 'avahi' (GID 558).
Successfully dropped root privileges.
avahi-daemon 0.8 starting up.
Loading service file /usr/local/etc/avahi/services/sftp-ssh.service.
Loading service file /usr/local/etc/avahi/services/ssh.service.
Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.43.45.
New relevant interface wlan0.IPv4 for mDNS.
Joining mDNS multicast group on interface lo0.IPv6 with address ::1.
New relevant interface lo0.IPv6 for mDNS.
Joining mDNS multicast group on interface lo0.IPv4 with address 127.0.0.1.
New relevant interface lo0.IPv4 for mDNS.
Network interface enumeration completed.
Registering new address record for 192.168.43.45 on wlan0.IPv4.
Registering new address record for ::1 on lo0.*.
Registering new address record for 127.0.0.1 on lo0.IPv4.
simple-protocol.c: Got RESOLVE-ADDRESS request for '192.168.43.45'.
Server startup complete. Host name is redstar.local. Local service cookie is 1440748168.
Service "redstar" (/usr/local/etc/avahi/services/ssh.service) successfully established.
Service "redstar" (/usr/local/etc/avahi/services/sftp-ssh.service) successfully established.

Thanks for your help!

evverx commented 7 months ago

Got it. Could you paste the avahi logs from bluestar.local? Messages where it joins/leaves multicast groups and register names should hopefully help to figure out why it doesn't reply to queries any more.

lliendo commented 7 months ago

Sure can do, but I need to restart it and will likely start working as with redstar.local... So should I simply restart avahi in bluestar.local or do you want me to also launch tcpdump in other hosts?

evverx commented 7 months ago

It should start working once it's restarted. I was hoping that the logs of the current running instance of avahi were available. My guess was that avahi left the multicast group and failed to join it again for some reason (there was some bug report where things like that happened on FreeBSD but it wasn't clear whether it was avahi failing to keep track the interfaces or a firmware/driver bug somewhere).

I think it should be fine to restart avahi on bluestart.local. It would be great if you could keep the logs somewhere should that happen again. The packet captures show that the connectivity is fine so probably there is no need to run it in the background but if it's possible to keep capturing stuff it would help next time too.

lliendo commented 7 months ago

Ok, I'm going to see then if there's some sort of hook after possibly getting an address from dhcp and force avahi to restart as that seems like a workaround. So from avahi side as far as I understand everything is ok there are no issues?

Once again thanks for your time!

evverx commented 7 months ago

I can't say for sure that it isn't an avahi issue. The problem is that it isn't clear what happens when avahi stops replying. It could have something to do with the way avahi interacts with the network interfaces (caused by an avahi bug or the way it's notified by the kernel and in that case it isn't an avahi bug) or it could be something else. I'll keep the issue open just in case but yes restarting it should help to get the issue around.

lliendo commented 7 months ago

Ok, I've been playing around (in FreeBSD) and so far I can say that things are working properly at the moment. Just for the record here's what I've done.

The /etc/nsswitch.conf file now contains (along other lines):

hosts: files mdns4_minimal mdns4 [notfound=return] dns

The /usr/local/etc/avahi/avahi-daemon.conf file contains the following modified options:

publish-addresses=yes
publish-workstation=yes

About the publish-workstation=yes option I'm not entirely sure but I followed this post (perhaps is not needed anyways and later on could be turned off, I haven't tested this yet).

And finally I'm forcing the avahi-daemon to be restarted each time dhclient reconfigures the interface(s) (I think this seems to be the problem solver). This is done through the /etc/dhclient-enter-hooks file (which in turn is sourced by the /sbin/dhclient-script file). I've added to /etc/dhclient-enter-hooks:

# Restart the avahi daemon each time dhcp configures interfaces. 
# It might resolve host name resolution after the link goes down and up again.
case $reason in
BOUND|RENEW|REBIND|REBOOT)
    service avahi-daemon restart
    sleep 1
    ;;
esac

Note that /etc/dhclient-enter-hooks might not exist (in that case you need to create it).

The FreeBSD packages that I've installed on my systems are: mdnsd, nss_mdns and of course avahi.

I hope this helps other FreeBSD folks maybe facing similar issues. Again as I said before things are working now but can't be 100% sure that this is bullet-proof. On Linux I haven't done any tweaks at all.