networkd 在启动时没有启动 eth0

networkd 在启动时没有启动 eth0

我已经在技嘉 brix pro 上安装了 Debian 8,除了网络之外,一切似乎都运行正常。

我已启用systemd-networkd.service、禁用networking.servicenetwork在中创建了适当的文件/etc/systemd/network。我还配置并启用了wpasupplicant无线适配器。

系统启动时,它会找到wlan0.network文件,打开界面,检测链接并正常运行,但由于某种原因,它看不到(或没有记录它看到)eth0.network我创建的文件。它没有检测到链接,也没有打开eth0

系统完全启动后,我可以运行systemctl restart systemd-networkd.serviceifup eth0,它会调出界面并正确配置它,此时它就可以正常工作了。它只是不会在启动时调出它。

/etc/systemd/network/wlan0.network

[Match]
Name=wlan0

[Network]
Address=192.168.1.21/24
DNS=192.168.1.1

/etc/systemd/network/eth0.network

[Match]
Name=eth0

[Network]
Address=192.168.1.10/24
Gateway=192.168.1.1
DNS=192.168.1.1

网际协议连接

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether fc:aa:14:db:cf:40 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether dc:85:de:ee:96:af brd ff:ff:ff:ff:ff:ff

lspci-v

03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
        Subsystem: Gigabyte Technology Co., Ltd Motherboard
        Flags: bus master, fast devsel, latency 0, IRQ 43
        I/O ports at d000 [size=256]
        Memory at f7c00000 (64-bit, non-prefetchable) [size=4K]
        Memory at f0000000 (64-bit, prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 01
        Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
        Capabilities: [170] Latency Tolerance Reporting
        Kernel driver in use: r8168

日志控制

kernel: r8168 Gigabit Ethernet driver 8.040.00-NAPI loaded
kernel: r8168 0000:03:00.0: irq 43 for MSI/MSI-X

...

kernel: r8168: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
kernel: r8168  Copyright (C) 2015  Realtek NIC software team <[email protected]>
                    This program comes with ABSOLUTELY NO WARRANTY; for details, please see <http://www.gnu.org/licenses/>.
                    This is free software, and you are welcome to redistribute it under certain conditions; see <http://www.gnu.org/licenses/>.

...

systemd-networkd[456]: wlan0           : link 3 added
systemd-networkd[456]: wlan0           : udev initialized link
systemd-networkd[456]: wlan0           : flags change: +UP +RUNNING +MULTICAST +BROADCAST
systemd-networkd[456]: wlan0           : flags change: -RUNNING
systemd-networkd[456]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=H
systemd-networkd[456]: sd-rtnl: discarding 20 bytes of incoming message
systemd-networkd[456]: wlan0           : link state is up-to-date
systemd-networkd[456]: wlan0           : found matching network '/etc/systemd/network/wlan0.network'
systemd-networkd[456]: wlan0           : enslaved
systemd-networkd[456]: wlan0           : setting addresses
systemd-networkd[456]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.2 object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=
systemd-networkd[456]: Got message type=signal sender=org.freedesktop.DBus destination=:1.2 object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAc
systemd-networkd[456]: sd-rtnl: discarding 20 bytes of incoming message
systemd-networkd[456]: rtnl: received address for a nonexistent link, ignoring
systemd-networkd[456]: rtnl: received address for a nonexistent link, ignoring
systemd-networkd[456]: wlan0           : added address: 192.168.1.21/24
systemd-networkd[456]: wlan0           : addresses set
systemd-networkd[456]: wlan0           : link configured

systemctl status systemd-networkd.service (从启动开始)

systemd-networkd[456]: sd-rtnl: discarding 20 bytes of incoming message
systemd-networkd[456]: rtnl: received address for a nonexistent link, ignoring
systemd-networkd[456]: rtnl: received address for a nonexistent link, ignoring
systemd-networkd[456]: wlan0           : added address: 192.168.1.21/24
systemd-networkd[456]: wlan0           : addresses set
systemd-networkd[456]: wlan0           : link configured
systemd-networkd[456]: wlan0           : flags change: +LOWER_UP
systemd-networkd[456]: wlan0           : flags change: +RUNNING
systemd-networkd[456]: wlan0           : gained carrier
systemd-networkd[456]: wlan0           : added address: fe80::de85:deff:feee:96af/64

systemctl status systemd-networkd.service(重启 networkd 后)

systemd-networkd[877]: wlan0           : link configured
systemd-networkd[877]: eth0            : flags change: +UP
systemd-networkd[877]: eth0            : added address: 192.168.1.10/24
systemd-networkd[877]: eth0            : addresses set
systemd-networkd[877]: eth0            : setting routes
systemd-networkd[877]: eth0            : routes set
systemd-networkd[877]: eth0            : link configured
systemd-networkd[877]: eth0            : flags change: +LOWER_UP +RUNNING
systemd-networkd[877]: eth0            : gained carrier
systemd-networkd[877]: eth0            : added address: fe80::feaa:14ff:fedb:cf40/64

我还应该提供哪些信息来帮助找到解决方案?

更新

添加以下行/etc/network/interfaces并启用可修复networking.service此问题,并且所有内容都会在启动时出现,但我不想使用旧的 init.d 系统。我想使用新的 systemd-networkd,我想知道为什么在那个环境中会发生这种情况。

auto eth0
iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.1

编辑

wpa_supplicant.service丢失了,因为我已禁用它;networking.service启用了,因为它是目前唯一能正常工作的东西。

systemctl -t 服务

UNIT                                            LOAD   ACTIVE SUB     DESCRIPTION
acpid.service                                   loaded active running ACPI event daemon
atd.service                                     loaded active running Deferred execution scheduler
console-setup.service                           loaded active exited  LSB: Set console font and keymap
cron.service                                    loaded active running Regular background program processing daemon
dbus.service                                    loaded active running D-Bus System Message Bus
exim4.service                                   loaded active running LSB: exim Mail Transport Agent
[email protected]                              loaded active running Getty on tty1
kbd.service                                     loaded active exited  LSB: Prepare console
keyboard-setup.service                          loaded active exited  LSB: Set preliminary keymap
kmod-static-nodes.service                       loaded active exited  Create list of required static device nodes for the current kernel
lm-sensors.service                              loaded active exited  Initialize hardware monitoring sensors
networking.service                              loaded active exited  LSB: Raise network interfaces.
nfs-common.service                              loaded active exited  LSB: NFS support files common to client and server
rc-local.service                                loaded active exited  /etc/rc.local Compatibility
rpcbind.service                                 loaded active running LSB: RPC portmapper replacement
rsyslog.service                                 loaded active running System Logging Service
ssh.service                                     loaded active running OpenBSD Secure Shell server
systemd-backlight@backlight:acpi_video0.service loaded active exited  Load/Save Screen Backlight Brightness of backlight:acpi_video0
systemd-journald.service                        loaded active running Journal Service
systemd-logind.service                          loaded active running Login Service
systemd-modules-load.service                    loaded active exited  Load Kernel Modules
systemd-networkd.service                        loaded active running Network Service
systemd-random-seed.service                     loaded active exited  Load/Save Random Seed
systemd-remount-fs.service                      loaded active exited  Remount Root and Kernel File Systems
systemd-resolved.service                        loaded active running Network Name Resolution
[email protected]                  loaded active exited  Load/Save RF Kill Switch Status of rfkill0
systemd-setup-dgram-qlen.service                loaded active exited  Increase datagram queue length
systemd-sysctl.service                          loaded active exited  Apply Kernel Variables
systemd-tmpfiles-setup-dev.service              loaded active exited  Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service                  loaded active exited  Create Volatile Files and Directories
systemd-udev-trigger.service                    loaded active exited  udev Coldplug all Devices
systemd-udevd.service                           loaded active running udev Kernel Device Manager
systemd-update-utmp.service                     loaded active exited  Update UTMP about System Boot/Shutdown
systemd-user-sessions.service                   loaded active exited  Permit User Sessions
udev-finish.service                             loaded active exited  Copy rules generated while the root was ro

答案1

添加节来解决您的问题的原因/etc/networking/interfaces是您已启用networking.service。如果您查看该networking.service文件,您将看到(部分编辑):

[Unit]
SourcePath=/etc/init.d/networking
Description=LSB: Raise network interfaces.
.....
[Service]
.....
ExecStart=/etc/init.d/networking start
ExecStop=/etc/init.d/networking stop
ExecReload=/etc/init.d/networking reload

这清楚地表明这是提供与旧 SysV 脚本兼容性的服务,而您希望避免这种情况。

虽然没有在任何地方明确说明这一点(我找不到!),但我猜测这与 相冲突systemd-networkd.service,尽管与 SysV 不兼容,但它可以提供完全相同的服务。

所以我的猜测是禁用networking,然后重新启动以检查这是(唯一的)解决方案。

答案2

这里有类似的症状。

日志br0: DHCPv6 lease lost让我产生了怀疑:

root@lorank8:/home/bue# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-03-08 09:02:14 UTC; 2min 42s ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 906 (systemd-network)
   Status: "Processing requests..."
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/systemd-networkd.service
           └─906 /lib/systemd/systemd-networkd

Mar 08 09:02:22 lorank8 systemd-networkd[906]: br0: Lost carrier
Mar 08 09:02:22 lorank8 systemd-networkd[906]: br0: DHCPv6 lease lost
Mar 08 09:02:27 lorank8 systemd-networkd[906]: eth0: Gained IPv6LL
Mar 08 09:02:30 lorank8 systemd-networkd[906]: usb0: Gained carrier
Mar 08 09:02:30 lorank8 systemd-networkd[906]: usb1: Gained carrier
Mar 08 09:02:31 lorank8 systemd-networkd[906]: usb0: Gained IPv6LL
Mar 08 09:02:31 lorank8 systemd-networkd[906]: usb1: Gained IPv6LL

connman.service 干扰了 systemd-networkd

禁用 connman 后,bridge 和 eth0 按预期在启动时出现。

相关内容