The networkd daemon failed to bring up the eth0 interface because its configuration specified a subnet mask that was not a valid CIDR notation.
Common Causes and Fixes
1. Invalid Subnet Mask/CIDR Notation
- Diagnosis: Check the network configuration file for
eth0. Look for anAddress=line.cat /etc/systemd/network/eth0.network - Cause: The
Address=line expects an IP address followed by a slash and a CIDR prefix length (e.g.,192.168.1.10/24). Incorrect formats like192.168.1.10/255.255.255.0or192.168.1.10without a prefix will causenetworkdto fail. - Fix: Edit the file and correct the
Address=line to use valid CIDR notation.
This works because# Example: Change from invalid to valid # Original: Address=192.168.1.10/255.255.255.0 # Corrected: Address=192.168.1.10/24 # Or if no mask was provided: # Original: Address=192.168.1.10 # Corrected: Address=192.168.1.10/24systemd-networkdstrictly enforces the CIDR format for IP address assignment. - Restart:
sudo systemctl restart systemd-networkd
2. Missing DHCP=yes or DHCP=ipv4 in [Network] Section
- Diagnosis: Examine the
[Network]section of theeth0.networkfile.cat /etc/systemd/network/eth0.network | grep DHCP - Cause: If the interface is intended to obtain an IP address via DHCP, but
DHCP=is not set toyesoripv4,networkdwill not attempt to request an IP from a DHCP server. - Fix: Add or correct the
DHCP=line in the[Network]section.
This explicitly tells[Network] DHCP=yesnetworkdto use DHCP for IPv4 address assignment on this interface. - Restart:
sudo systemctl restart systemd-networkd
3. Incorrect [Match] Section
- Diagnosis: Verify the
[Match]section ineth0.networkcorresponds to the actual interface name.cat /etc/systemd/network/eth0.network | grep Name - Cause: If the
Name=line in the[Match]section does not exactly match the interface name (e.g.,eth0vs.enp0s3),networkdwill not apply the configuration to the intended interface. Interface names can change based on hardware and kernel modules. - Fix: Update the
Name=line to match the actual interface name. You can find the actual name usingip a.
This ensures that the configuration block is correctly associated with the physical or virtual network device.[Match] Name=eth0 - Restart:
sudo systemctl restart systemd-networkd
4. Missing or Incorrect [Link] Section for Static Configuration
- Diagnosis: For static IP configurations, check for the presence and correctness of the
[Link]section.cat /etc/systemd/network/eth0.network | grep MACAddress - Cause: While not strictly required for basic static IP assignment, if you’re using
MACAddress=in the[Link]section for a specific hardware address, and it’s incorrect or malformed,networkdmight fail to initialize the link. - Fix: Ensure the
MACAddress=is correctly formatted (e.g.,00:11:22:AA:BB:CC) or remove it if not needed.
This ensures[Link] MACAddress=00:11:22:AA:BB:CCnetworkdcan properly configure the network hardware if a specific MAC address is intended. - Restart:
sudo systemctl restart systemd-networkd
5. Unloaded Kernel Module for Network Card
- Diagnosis: Check if the network card’s driver is loaded.
lsmod | grep <driver_name> # Or check dmesg for errors related to the network card dmesg | grep -i eth0 - Cause: The necessary kernel module for your network interface card might not be loaded, preventing the
eth0device from being recognized by the system. This is often seen after kernel updates or if the module is explicitly blacklisted. - Fix: Manually load the module or ensure it’s configured to load at boot.
Loading the module makes the kernel aware of the hardware and provides the necessary functions for the network interface.sudo modprobe <driver_name> # To make it persistent, add to /etc/modules-load.d/ echo "<driver_name>" | sudo tee /etc/modules-load.d/network.conf - Restart:
sudo systemctl restart systemd-networkd
6. Conflicting Network Management Services
- Diagnosis: Check if other network management daemons are running.
systemctl status NetworkManager systemctl status networking - Cause: If
NetworkManageror the oldernetworkingservice (fromifupdown) is active and configured to manageeth0,systemd-networkdmight conflict or be unable to take control of the interface. - Fix: Disable and stop any conflicting services.
Disabling other managers ensuressudo systemctl stop NetworkManager sudo systemctl disable NetworkManager # If using the older init system: # sudo service networking stop # sudo update-rc.d networking disablesystemd-networkdhas exclusive control over network interface configuration. - Restart:
sudo systemctl restart systemd-networkd
After fixing these issues, you might encounter an error related to DNS resolution if the DNS= line in your .network file is incorrect or missing and you’re not using DHCP to obtain DNS servers.