刚刚安装了 ubuntu 服务器 18.04。我无法使用 systemd-networkd 获得 dhcp 租约,但使用 dhclient 可以正常工作。
使用 SYSTEMD_LOG_LEVEL=debug 我得到:
$ journalctl
...
Apr 29 10:14:09 computer systemd-networkd[2169]: enp3s0: Link state is up-to-date
Apr 29 10:14:09 computer systemd-networkd[2169]: enp3s0: found matching network '/etc/systemd/network/10-netplan-enp3s0.network'
Apr 29 10:14:09 computer systemd-networkd[2169]: wlp2s0: Link is not managed by us
Apr 29 10:14:09 computer systemd-networkd[2169]: lo: Link is not managed by us
Apr 29 10:14:09 computer systemd-networkd[2169]: LLDP: Started LLDP client
Apr 29 10:14:09 computer systemd-networkd[2169]: enp3s0: Started LLDP.
Apr 29 10:14:09 computer systemd-networkd[2169]: enp3s0: Acquiring DHCPv4 lease
Apr 29 10:14:09 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): STARTED on ifindex 2
Apr 29 10:14:09 computer systemd-networkd[2169]: enp3s0: Discovering IPv6 routers
Apr 29 10:14:09 computer systemd-networkd[2169]: NDISC: Started IPv6 Router Solicitation client
Apr 29 10:14:09 computer systemd-networkd[2169]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Apr 29 10:14:09 computer systemd-networkd[2169]: NDISC: Sent Router Solicitation, next solicitation in 4s
Apr 29 10:14:09 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:14:09 computer systemd-networkd[2169]: lo: Link state is up-to-date
Apr 29 10:14:09 computer systemd-networkd[2169]: lo: Unmanaged
Apr 29 10:14:09 computer systemd-networkd[2169]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Apr 29 10:14:09 computer systemd-timesyncd[581]: Network configuration changed, trying to establish connection.
Apr 29 10:14:09 computer sudo[2164]: pam_unix(sudo:session): session closed for user root
Apr 29 10:14:11 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:14:12 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:14:14 computer systemd-networkd[2169]: NDISC: Sent Router Solicitation, next solicitation in 8s
Apr 29 10:14:16 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:14:21 computer systemd-networkd[2169]: NDISC: No RA received before link confirmation timeout
Apr 29 10:14:21 computer systemd-networkd[2169]: NDISC: Invoking callback for 't'.
Apr 29 10:14:22 computer systemd-networkd[2169]: NDISC: Sent Router Solicitation, next solicitation in 17s
Apr 29 10:14:25 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:14:39 computer systemd-networkd[2169]: NDISC: Sent Router Solicitation, next solicitation in 34s
Apr 29 10:14:41 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:15:14 computer systemd-networkd[2169]: NDISC: Sent Router Solicitation, next solicitation in 1min 10s
Apr 29 10:15:14 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
Apr 29 10:16:18 computer systemd-networkd[2169]: DHCP CLIENT (0xb7fc15eb): DISCOVER
当我使用 dhcpd 时,一切正常:
Apr 29 10:33:00 computer sudo[2213]: user : TTY=tty1 ; PWD=/home/user ; USER=root ; COMMAND=/sbin/dhclient -v enp3s0
Apr 29 10:33:00 computer sudo[2213]: pam_unix(sudo:session): session opened for user root by user(uid=0)
Apr 29 10:33:00 computer dhclient[2214]: Internet Systems Consortium DHCP Client 4.3.5
Apr 29 10:33:00 computer dhclient[2214]: Copyright 2004-2016 Internet Systems Consortium.
Apr 29 10:33:00 computer dhclient[2214]: All rights reserved.
Apr 29 10:33:00 computer dhclient[2214]: For info, please visit https://www.isc.org/software/dhcp/
Apr 29 10:33:00 computer dhclient[2214]:
Apr 29 10:33:00 computer dhclient[2214]: Listening on LPF/enp3s0/c0:3f:d5:63:0a:30
Apr 29 10:33:00 computer dhclient[2214]: Sending on LPF/enp3s0/c0:3f:d5:63:0a:30
Apr 29 10:33:00 computer dhclient[2214]: Sending on Socket/fallback
Apr 29 10:33:00 computer dhclient[2214]: DHCPDISCOVER on enp3s0 to 255.255.255.255 port 67 interval 3 (xid=0x536ea71d)
Apr 29 10:33:02 computer dhclient[2214]: DHCPREQUEST of 192.168.64.102 on enp3s0 to 255.255.255.255 port 67 (xid=0x1da76e53)
Apr 29 10:33:02 computer dhclient[2214]: DHCPOFFER of 192.168.64.102 from 192.168.64.1
Apr 29 10:33:02 computer dhclient[2214]: DHCPACK of 192.168.64.102 from 192.168.64.1
Apr 29 10:33:02 computer systemd-networkd[2169]: enp3s0: Adding address: 192.168.64.102/24 (valid forever)
我的问题是:
- 有没有人可能看到这一点并知道原因可能是什么?
- 有什么方法可以找出为什么它无法与 dhcp 服务器通信?
- 有没有一种安全的方法(对系统更新很强大)让它使用 dhclient 来代替?
在我必须离开之前,我有有限的时间来完成这项工作,我需要知道它会在没有本地干预的情况下重新上线,以防重启。
编辑:请求的信息:
$ sudo lshw -C network
*-network DISABLED
description: Wireless interface
product: Wireless 7260
vendor: Intel Corporation
physical id: 0
bus info: pci@0000:02:00.0
logical name: wlp2s0
version: 73
serial: ac:7b:a1:43:12:c8
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=4.15.0-48-generic firmware=17.948900127.0 latency=0 link=no multicast=yes wireless=IEEE 802.11
resources: irq:92 memory:d0700000-d0701fff
*-network
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
vendor: Realtek Semiconductor Co., Ltd.
physical id: 0
bus info: pci@0000:03:00.0
logical name: enp3s0
version: 0c
serial: c0:3f:d5:63:0a:30
size: 100Mbit/s
capacity: 1Gbit/s
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168g-2_0.0.1 02/06/13 ip=192.168.64.102 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
resources: irq:18 ioport:e000(size=256) memory:d0604000-d0604fff memory:d0600000-d0603fff
网络计划:
$ cat /etc/netplan/*.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: true
还:
$ cat /run/systemd/network/*
[Match]
Name=enp3s0
[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
[DHCP]
UseMTU=true
RouteMetric=100
我也试过没有 [DHCP] 节和没有 LinkLocalAddressing 行(当然应该没关系)无济于事。
谢谢。
编辑 2:对于设置的后期阶段,我需要设置一个 pppoe 接口。我现在意识到 netplan 和 networkd 不支持 pppoe 配置,所以我放弃这个并回到 NetworkManager。