The Dropped Connection
To maximize battery life on laptops, Ubuntu and the Linux kernel employ aggressive power management strategies. One of these strategies is Runtime Power Management (Runtime PM) for PCI devices. If Ubuntu detects that a specific hardware component, such as your Ethernet network interface card (NIC), has been idle for a short period, it may automatically suspend the device to save a few milliwatts of power. However, on certain hardware configurations, this can cause the network interface to drop the connection entirely, fail to wake up when network traffic resumes, or cause intermittent SSH disconnects when working on a headless server.
Disabling Network Interface Power Saving
To guarantee a stable, uninterrupted wired connection and stop Ubuntu from automatically suspending your network interface, you must configure the kernel module parameters or adjust your power management daemon.
If you are using a standard Ubuntu desktop, the issue is often caused by the power-profiles-daemon or TLP (if installed). The most robust way to prevent PCI device suspension is via a udev rule. Open a terminal (Ctrl+Alt+T) and run sudo nano /etc/udev/rules.d/10-disable-network-pm.rules. Paste the following line into the new file: ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", RUN+="/sbin/ethtool -s %k wol g" (replace eth* with en* if your interface uses the newer naming convention like `enp3s0`). Save (Ctrl+O, Enter) and exit (Ctrl+X). Next, to specifically disable PCI runtime power management for the device, you would find its PCI ID using lspci and set its power/control file to on instead of auto via a startup script or rc.local. Reboot your system to ensure the changes take effect.