即使使用静态配置文件,dhcpcd 也会查询 IP 地址吗?

即使使用静态配置文件,dhcpcd 也会查询 IP 地址吗?

情况是这样的:我配置了我的 Raspberry Pi/etc/dhcpcd.conf文件以便使用具有静态 IP 地址的静态配置文件。

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
alarm_host

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name, domain_search, host_name
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
noipv4ll

interface eth0
static ip_address=172.16.30.90/16
static routers=172.16.10.254
static domain_name_servers=8.8.8.8 8.8.4.4

但是如果我检查 eth0 上的实际活动路由,我会得到以下输出:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:3a:e8:94 brd ff:ff:ff:ff:ff:ff
    inet 172.16.1.89/16 brd 172.16.255.255 scope global dynamic eth0
       valid_lft 680785sec preferred_lft 680785sec
    inet 172.16.30.90/16 brd 172.16.255.255 scope global secondary noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::6610:ec0c:c173:16c2/64 scope link 
       valid_lft forever preferred_lft forever

我不知道为什么 dhcpcd 要求提供 IP 地址,即使我为该接口设置了静态配置文件。我可能错过了一些东西,但我不知道是什么。我怎样才能避免这种情况?

我在 Raspberry Pi 4 上使用 Arch Linux。

答案1

对于遇到这种情况的人,请看这里: https://wiki.archlinux.org/title/Dhcpcd#Running

您必须禁用 dhcpcd.service 并为您需要的接口启用它(例如:[电子邮件受保护])。这应该可以解决问题:

sudo systemctl disable --now dhcpcd.service
#sudo systemctl enable --now [email protected]
sudo ip link set eth0 down
sudo ip link set eth0 up

ps:我很乐意私下讨论 Arch ARM,了解您在armv7和armv8(aarch64)之间运行哪个版本。 ;)

相关内容