Avahi/mDNS 不起作用

Avahi/mDNS 不起作用

我在使我的服务器通过 mDNS/Avahi 互相通信时遇到了问题。

我有两台服务器,一台 Ubuntu 服务器和一台 Raspberry PI。

user@WORKCOM9001~ ()$ sudo service avahi-daemon status
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2020-07-01 21:54:45 PDT; 4min 6s ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 1101 (avahi-daemon)
     Status: "avahi-daemon 0.7 starting up."
      Tasks: 2 (limit: 18921)
     Memory: 2.5M
     CGroup: /system.slice/avahi-daemon.service
             ├─1101 avahi-daemon: running [WORKCOM9001.local]
             └─1160 avahi-daemon: chroot helper

在我的 Raspberry PI 上我得到:

pi@raspberrypi2:~ $ sudo service avahi-daemon status
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-07-01 18:36:47 PDT; 3h 21min ago
 Main PID: 276 (avahi-daemon)
   Status: "avahi-daemon 0.7 starting up."
   Memory: 956.0K
   CGroup: /system.slice/avahi-daemon.service
           ├─276 avahi-daemon: running [raspberrypi2.local]
           └─287 avahi-daemon: chroot helper

我可以使用 IP 地址 (即) 从另一个网络 ping 和 SSH 到彼此,但使用主机名 +则不行。ssh [email protected].local

avahi-browse没有显示另一个设备。(即来自我的服务器):

+ wlp61s0 IPv6 EPSON XP-830 Series                           _uscan._tcp          local
+ wlp61s0 IPv4 EPSON XP-830 Series                           _uscan._tcp          local
+ wlp61s0 IPv6 EPSON XP-830 Series                           _privet._tcp         local
+ wlp61s0 IPv4 EPSON XP-830 Series                           _privet._tcp         local
+ wlp61s0 IPv6 EPSON XP-830 Series                           Secure Internet Printer local
+ wlp61s0 IPv4 EPSON XP-830 Series                           Secure Internet Printer local
+ wlp61s0 IPv6 EPSON XP-830 Series                           Internet Printer     local
+ wlp61s0 IPv4 EPSON XP-830 Series                           Internet Printer     local
+ wlp61s0 IPv6 EPSON XP-830 Series                           _scanner._tcp        local
+ wlp61s0 IPv4 EPSON XP-830 Series                           _scanner._tcp        local
+ wlp61s0 IPv6 EPSON XP-830 Series                           Microsoft Windows Network local
+ wlp61s0 IPv4 EPSON XP-830 Series                           Microsoft Windows Network local
+ wlp61s0 IPv6 EPSON XP-830 Series                           Web Site             local
+ wlp61s0 IPv4 EPSON XP-830 Series                           Web Site             local
+ wlp61s0 IPv6 EPSON XP-830 Series                           PDL Printer          local
+ wlp61s0 IPv4 EPSON XP-830 Series                           PDL Printer          local
+ wlp61s0 IPv6 EPSON XP-830 Series                           UNIX Printer         local
+ wlp61s0 IPv4 EPSON XP-830 Series                           UNIX Printer         local
+ wlp61s0 IPv6 5c:1d:d9:8f:a4:05@fe80::5e1d:d9ff:fe8f:a405   _apple-mobdev2._tcp  local
+ wlp61s0 IPv4 5c:1d:d9:8f:a4:05@fe80::5e1d:d9ff:fe8f:a405   _apple-mobdev2._tcp  local
+ wlp61s0 IPv4 Chromecast-Ultra-a41f56bb802c5975b2ecb845394ab75d _googlecast._tcp     local
+ wlp61s0 IPv4 a41f56bb-802c-5975-b2ec-b845394ab75d          _googlezone._tcp     local

来自 Raspberry Pi:

+  wlan0 IPv6 EPSON XP-830 Series                           Internet Printer     local
+  wlan0 IPv4 EPSON XP-830 Series                           Internet Printer     local
+  wlan0 IPv6 EPSON XP-830 Series                           Secure Internet Printer local
+  wlan0 IPv4 EPSON XP-830 Series                           Secure Internet Printer local
+  wlan0 IPv4 5c:1d:d9:8f:a4:05@fe80::5e1d:d9ff:fe8f:a405   _apple-mobdev2._tcp  local
+  wlan0 IPv6 5c:1d:d9:8f:a4:05@fe80::5e1d:d9ff:fe8f:a405   _apple-mobdev2._tcp  local
+  wlan0 IPv6 EPSON XP-830 Series                           _privet._tcp         local
+  wlan0 IPv4 EPSON XP-830 Series                           _privet._tcp         local
+  wlan0 IPv4 a41f56bb-802c-5975-b2ec-b845394ab75d          _googlezone._tcp     local
+  wlan0 IPv4 EPSON XP-830 Series                           UNIX Printer         local
+  wlan0 IPv4 EPSON XP-830 Series                           PDL Printer          local
+  wlan0 IPv4 EPSON XP-830 Series                           Web Site             local
+  wlan0 IPv4 EPSON XP-830 Series                           Microsoft Windows Network local
+  wlan0 IPv4 EPSON XP-830 Series                           _scanner._tcp        local
+  wlan0 IPv4 EPSON XP-830 Series                           _uscan._tcp          local
+  wlan0 IPv6 EPSON XP-830 Series                           UNIX Printer         local
+  wlan0 IPv6 EPSON XP-830 Series                           PDL Printer          local
+  wlan0 IPv6 EPSON XP-830 Series                           Web Site             local
+  wlan0 IPv6 EPSON XP-830 Series                           Microsoft Windows Network local
+  wlan0 IPv6 EPSON XP-830 Series                           _scanner._tcp        local
+  wlan0 IPv6 EPSON XP-830 Series                           _uscan._tcp          local
+  wlan0 IPv4 Chromecast-Ultra-a41f56bb802c5975b2ecb845394ab75d _googlecast._tcp     local

谁能帮我这个?

谢谢

答案1

设备需要被处理为name.local

工作 LAN 设置

  • LAN:2 * Mac、1 * 网络连接打印机、2 * VM (Ubuntu 20.04)、1 * pi
  • avahi-daemonUbuntu VM 和 pi作为服务 运行
    $ sudo service avahi-daemon status
    ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
         Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
         Active: active (running) since Thu 2020-07-02 12:00:59 UTC; 7h left
    TriggeredBy: ● avahi-daemon.socket
       Main PID: 784 (avahi-daemon)
         Status: "avahi-daemon 0.7 starting up."
          Tasks: 2 (limit: 1069)
         Memory: 1.3M
         CGroup: /system.slice/avahi-daemon.service
                 ├─784 avahi-daemon: running [mcs-ui.local]
                 └─828 avahi-daemon: chroot helper
    
  • 所有机器都可以互相访问,name.local并且ping printer.local
  • avahi-browse仅安装在一台虚拟机上,并且没有列出 LAN 上的所有设备

答案2

安装sudo apt-get install avahi-autoipd对我来说很有帮助。

avahi-autoipd主要用于缺少 DHCP 服务器的 ad-hoc 网络。

相关内容