Debian – networkd is not bringing eth0 up at boot

debian-jessiesystemd

I've installed Debian 8 on a gigabyte brix pro and everything seems to work properly except for networking.

I've enabled systemd-networkd.service, disabled networking.service and created the appropriate network files in /etc/systemd/network. I've configured and enabled wpasupplicant for the wireless adapter as well.

When the system boots, it finds the wlan0.network file, brings the interface up, detects a link and works perfectly but for some reason it doesn't see (or doesn't log that it sees) the eth0.network file I created. It does not detect a link and does not bring eth0 up at all.

After the system is fully booted, I can run systemctl restart systemd-networkd.service or ifup eth0 and it will bring the interface up and properly configure it at which point it works fine. It just won't bring it up on boot.

/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

ip link

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

journalctl

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 <nicfae@realtek.com>
                    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 (from boot)

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 (after restart of 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

What other information should I provide to help find a solution to this?

UPDATE

Adding the following lines to /etc/network/interfaces and enabling networking.service fixes the issue and everything comes up at boot but I would rather not use the old init.d system. I want to use the new systemd-networkd and I'd like to know why this is happening in that environment.

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

EDIT

wpa_supplicant.service is missing because I've since disabled it and networking.service is enabled because it's the only thing that is currently working.

systemctl -t service

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
getty@tty1.service                              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
systemd-rfkill@rfkill0.service                  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

Best Answer

The reason why adding a stanza to /etc/networking/interfaces solves your problem is that you have the networking.service enabled. If you look at the networking.service file, you will see (partly edited):

[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

which clearly shows this is the service that provides compatibility with the old SysV script, which you wish to avoid.

Though this is not clearly stated anywhere (that I could find!), my guess is that this conflicts with systemd-networkd.service, which can provide exactly the same service, albeit without the compatibility with SysV.

So my guess is to disable networking, and to reboot to check that this is (the only piece of) the solution.

Related Question