In this lesson, you will learn how to influence the order in which Linux initializes network interfaces during the early stages of the boot process to ensure critical links are ready before dependent services start.
The Challenge of Boot-Time Race Conditions
On a modern Linux system, interface initialization often happens in parallel. While this speeds up boot times, it creates a "race" between the kernel’s driver initialization, the udev device manager, and your network configuration tool (like systemd-networkd or NetworkManager). If a high-priority interface—such as an uplink to a storage area network (SAN)—is not ready when a service like nfs-client attempts to mount a remote share, the boot process may stall or fail.
Controlling Initialization via udev Rules
To strictly control the order, we move beyond standard configuration files and tap into udev. By default, Linux enumerates interfaces based on PCI bus discovery, which is non-deterministic. We can force a specific order by assigning an interface a lower link_priority or by utilizing systemd dependencies.
If you are using systemd-networkd, you can explicitly ensure an interface is "Required" for the network to be considered "online" by creating a link file in /etc/systemd/network/:
# /etc/systemd/network/10-primary-uplink.link
[Match]
MACAddress=00:11:22:33:44:55
[Link]
# Ensures the kernel waits for this device before signaling network readiness
RequiredForOnline=yes
By setting RequiredForOnline=yes, you instruct the network stack to treat this interface as a gatekeeper. The system will hold off on transitioning to the "network-online" target until this interface has successfully negotiated a link and received an IP address.
Why Order Matters
Beyond simple availability, interface priority is critical when you have overlapping routes. If a secondary management interface accidentally comes up before your primary route, the kernel may populate the routing table with default gateways that point to the wrong upstream provider. Using these initialization hooks ensures that your "Default Gateway" interface is the first one fully prepared, preventing route flapping during the critical window when the kernel network heap is being populated.
Key Takeaway: You manage network interface priorities by leveraging udev or systemd-networkd flags to force critical links to meet their "Ready" state before the system transitions to high-level network services.