我家里有 2 个 Raspberry Pi,连接时有时无,均从我的 DHCP 服务器获取 dhcp 地址。
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.60.5 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::c487:63ce:160a:acd5 prefixlen 64 scopeid 0x20<link>
ether e4:5f:01:db:a0:00 txqueuelen 1000 (Ethernet)
RX packets 426505 bytes 46789104 (44.6 MiB)
RX errors 0 dropped 37337 overruns 0 frame 0
TX packets 336554 bytes 183810523 (175.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
然而ip a
显示:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether e4:5f:01:db:a0:00 brd ff:ff:ff:ff:ff:ff
inet 10.0.60.5/32 scope global eth0
valid_lft forever preferred_lft forever
inet 10.0.60.3/24 brd 10.0.60.255 scope global dynamic noprefixroute eth0
valid_lft 54817sec preferred_lft 44017sec
inet 10.0.60.3/32 scope global eth0
valid_lft forever preferred_lft forever
inet 10.0.60.130/32 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::c487:63ce:160a:acd5/64 scope link
valid_lft forever preferred_lft forever
使用 journalctl 搜索额外的 IP 地址会显示以下日志消息:
Apr 28 09:10:43 pi1 avahi-daemon[427]: Registering new address record for 10.0.60.5 on eth0.IPv4.
Apr 28 09:10:43 pi1 avahi-daemon[427]: Registering new address record for 10.0.60.3 on eth0.IPv4.
Apr 28 09:10:45 pi1 avahi-daemon[427]: Withdrawing address record for 10.0.60.3 on eth0.
Apr 28 09:10:45 pi1 avahi-daemon[427]: Registering new address record for 10.0.60.3 on eth0.IPv4.
Apr 28 09:10:45 pi1 avahi-daemon[427]: Got SIGHUP, reloading.
Apr 28 09:10:45 pi1 avahi-daemon[427]: No service file found in /etc/avahi/services.
Apr 28 17:04:37 pi1 avahi-daemon[427]: Withdrawing address record for 10.0.60.130 on eth0.
Apr 28 17:04:37 pi1 avahi-daemon[427]: Leaving mDNS multicast group on interface eth0.IPv4 with address 10.0.60.130.
Apr 28 17:04:37 pi1 avahi-daemon[427]: Joining mDNS multicast group on interface eth0.IPv4 with address 10.0.60.3.
Apr 28 17:04:40 pi1 avahi-daemon[427]: Registering new address record for 10.0.60.130 on eth0.IPv4.
为什么 avahi 请求新的 DHCP 地址,我该如何配置它以使用我的原始地址?注意:我确实为我的家庭 VLAN 启用了 mDNS 中继器。
编辑:据我所知,我没有运行任何其他 dhcp 客户端。NetworkManager 未安装,仅在 dhcpcd 中看到一个列出的 IP:4 月 28 日 21:10:45 pi1 dhcpcd[4202]: eth0: 从 10.0.60.1 提供 10.0.60.3
答案1
为什么 avahi 请求新的 DHCP 地址以及如何配置它以使用我的原始地址?
不是。你混淆了因果关系。Avahi-daemon 不是 DHCP 客户端;它的工作是反应对网络接口上的任何 IP 地址添加或删除,以便它可以通过 mDNS 正确地公布它们。
确保只运行一个 DHCP 客户端,但也要在整个 /etc 中查找额外的地址——它们看起来很像是被添加的静态地通过一些网络配置。