在一些 Linux 设备上(包括运行 Termux 的 Android 手机),我安装了 Avahi,它可以运行,但内部 .local 地址只能显示几分钟。几分钟后,当 .local 地址不再可见时,当我使用 检查时,它仍然在服务器本身上可用mdns-scan
,但在设备外部不可用。它在 Ubuntu 22.04 安装(包括 Raspberry Pi)中可以运行,但在 Rocky Linux 和 Termux(Android 下不使用 Android root 的子系统)上则不行。我的 Macbook 也一直在导出其 .local 域,但不是通过 Avahi 导出。但在所有情况下,avahi-daemon.conf
除了 之外看起来都一样,host-name
它在所有情况下都能正确导出,后两个 Linux 环境的时间有限。但是,在服务器本身上运行“mdns-scan”会在几分钟后停止导出,但仍然会识别自己的主机名。我甚至关闭了 Termux 上的 ipv6 和除 wifi 之外的任何其他网络。
:~$ mdns-scan
+ nothingphone._ssh._tcp.local
+ nothingphone._sftp-ssh._tcp.local
+ adb-000481423000975._adb._tcp.local
+ mymacbook._ssh._tcp.local
+ mymacbook._sftp-ssh._tcp.local
+ mymacbook._rfb._tcp.local
+ <hexstring>-supportsRP-19._apple-mobdev2._tcp.local
+ iPad Air 2._companion-link._tcp.local
^Cowsing ... - (aborted by Ctrl+C)
这表明nothingphone
avahi 仍然处于活动状态,但在重新启动 avahi-daemon 几分钟后无法在设备外部发现。是什么停止了这项服务?
# This file is part of avahi.
#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# avahi is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with avahi; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
# See avahi-daemon.conf(5) for more information on this configuration
# file!
[server]
host-name=nothingphone
#domain-name=local
#browse-domains=0pointer.de, zeroconf.org
use-ipv4=yes
use-ipv6=no
allow-interfaces=wlan0
#deny-interfaces=eth1
#check-response-ttl=no
#use-iff-running=no
enable-dbus=yes
#disallow-other-stacks=no
#allow-point-to-point=no
#cache-entries-max=4096
#clients-max=4096
#objects-per-client-max=1024
#entries-per-entry-group-max=32
ratelimit-interval-usec=1000000
ratelimit-burst=1000
[wide-area]
enable-wide-area=yes
[publish]
#disable-publishing=no
#disable-user-service-publishing=no
#add-service-cookie=no
#publish-addresses=yes
publish-hinfo=no
publish-workstation=no
#publish-domain=yes
#publish-dns-servers=192.168.50.1, 192.168.50.2
#publish-resolv-conf-dns-servers=yes
#publish-aaaa-on-ipv4=yes
#publish-a-on-ipv6=no
[reflector]
#enable-reflector=no
#reflect-ipv=no
#reflect-filters=_airplay._tcp.local,_raop._tcp.local
[rlimits]
#rlimit-as=
#rlimit-core=0
#rlimit-data=8388608
#rlimit-fsize=0
#rlimit-nofile=768
#rlimit-stack=8388608
#rlimit-nproc=3