Ubuntu 18.04、systemd-networkd、DHCP 并从 DHCP 服务器请求 192.168.0.2

Ubuntu 18.04、systemd-networkd、DHCP 并从 DHCP 服务器请求 192.168.0.2

我正在使用 systemd 配置两个网络接口。一个使用 DHCP,另一个使用静态 IP(v4 地址)。

# systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

我正在使用以下网络配置:

eth0:

# cat /etc/systemd/network/lan0.network
[Match]
    Name=eth0
[Network]
    DHCP=ipv4
    LLDP=no
[DHCP]
    ClientIdentifier=mac

eth1:

 # cat /etc/systemd/network/lan1.network
 [Match]
    Name=eth1
 [Link]
    RequiredForOnline=no
 [Network]
    ConfigureWithoutCarrier=true
    Address=192.168.1.2/24

引导加载程序(内核的组选项):

GRUB_CMDLINE_LINUX="ipv6.disable=1 net.ifnames=1 biosdevname=0"

禁用 IPv6 并启用旧式设备名称。

# journalctl -b -u systemd-networkd
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: Flags change: +LOWER_UP +RUNNING
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: Gained carrier
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: Acquiring DHCPv4 lease
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): STARTED on ifindex 2
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properti
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): DISCOVER
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): OFFER
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): REQUEST (requesting)
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): ACK
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): lease expires in 57s
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): T2 expires in 50s
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): T1 expires in 29s
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: DHCPv4 address 192.168.0.2/24 via 192.168.0.100
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: Updating address: 192.168.0.2/24 (valid for 1min)
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properti
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: DHCP error: could not get routes: No data available
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: eth0: Configured
Aug 06 14:01:52 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus
Aug 06 14:02:22 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): REQUEST (renewing)
Aug 06 14:02:43 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): REQUEST (rebinding)
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x70153129): EXPIRED
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: eth0: DHCP lease lost
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: eth0: Removing address 192.168.0.2
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): DISCOVER
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: eth0: Removing address: 192.168.0.2/24 (valid for 3s)
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properti
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): OFFER
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): REQUEST (requesting)
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): ACK
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): lease expires in 9min 57s
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): T2 expires in 8min 43s
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: DHCP CLIENT (0x13958afa): T1 expires in 4min 59s
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: eth0: DHCPv4 address 10.0.0.98/24 via 10.0.0.1
Aug 06 14:02:49 testpcdk458 systemd-networkd[518]: eth0: Updating address: 10.0.0.98/24 (valid for 10min)

为什么 DHCP 客户端尝试请求 192.168.0.2 两次?这是怎么回事?DHCP 服务器最终按照其配置提供 10.0.0.98,但这太浪费时间了。

这是一个测试系统,我需要它快速启动。问题不是功能性的,而是使用 DHCP 配置接口需要多长时间。

编辑:

所需信息:

 # ls -al /etc/resolv.conf

lrwxrwxrwx 1 root root 32 7 月 12 日 12:50 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf

 # ls -al /etc/netplan/
 total 16
 drwxr-xr-x   2 root root  4096 Aug  5 14:05 .
 drwxr-xr-x 131 root root 12288 Aug  6 13:11 ..

相关内容