我无法使用systemd-networkd
.基于这里,我应该能够在/etc/systemd/network/eth0.network
路径上使用以下代码设置静态IP:
[Match]
Name=enp1s0
[Address]
Address=10.1.10.9/24
Gateway=10.1.10.1
DNS=10.1.10.1
但我给出了以下systemd-networkd
服务日志:
May 15 13:49:45 xxx systemd[1]: Stopped Network Service.
May 15 13:49:59 xxx systemd[1]: Starting Network Service...
May 15 13:50:00 xxx systemd-networkd[481]: /etc/systemd/network/eth0.network:6: Unknown key name 'DNS' in section 'Address', ignoring.
May 15 13:50:00 xxx systemd-networkd[481]: eth0: Gained IPv6LL
May 15 13:50:00 xxx systemd-networkd[481]: Enumeration completed
May 15 13:50:00 xxx systemd[1]: Started Network Service.
May 15 13:50:00 xxx systemd-networkd[481]: eth0: IPv6 successfully enabled
May 15 13:50:00 xxx systemd-networkd[481]: eth0: DHCPv4 address 192.168.0.230/24 via 192.168.0.254
May 15 13:50:12 xxx systemd-networkd[481]: eth0: Configured
您可以在下面找到我的硬件和软件规格:
root@hostname:/etc/systemd/network# hostnamectl
Static hostname: hostname
Icon name: computer
Machine ID:
Boot ID:
Operating System: NXP i.MX Release Distro 5.4-zeus (zeus)
Kernel: Linux 4.1.15+
Architecture: arm
答案1
您的网络设备名为 eth0:
May 15 13:50:00 xxx systemd-networkd[481]: eth0: IPv6 successfully enabled
但您的规则仅适用于名为 的接口enp1s0
:
[Match]
Name=enp1s0
这在 arch wiki 中有介绍([匹配] 部分)和手册页 systemd.networkd (部分 [匹配部分选项])。的值Name
必须与设备名称匹配,但enp1s0
不匹配eth0
。您应该将规则更改为Name=eth0
.