nm-online
Check network connectivity status
TLDR
Find out whether the network is connected and print the result to stdout
Wait n seconds for a connection (30 by default)
SYNOPSIS
nm-online [OPTIONS]
PARAMETERS
--help
Show help options.
--version
Show program version.
-q, --quiet
Suppress unnecessary output.
-w, --wait
Wait for
-x, --exit-if-up
Exit immediately with success if already online.
-s, --system-wait
Use systemd readiness protocol (if available).
-n, --no-wait
Do not wait for NetworkManager to become available (for use in systemd services).
DESCRIPTION
The nm-online command is a utility provided by NetworkManager to check if the system is connected to the network and can reach the internet. It interacts with the NetworkManager daemon to determine the network state. nm-online checks if there is at least one network connection available and activated and if the system can reach configured targets like DNS servers, default gateways, or specific hosts. The command can be used in scripts or system startup processes to ensure that the network is ready before starting network-dependent services. It allows to prevent service starting before the network is up, decreasing errors and improving reliability. It's a useful tool for managing network dependencies in a Linux environment.
Unlike a simple ping, nm-online leverages NetworkManager's internal state, providing a more robust assessment of network readiness. Using nm-online can also help manage systems that use NetworkManager to provide network services for other applications.
CAVEATS
nm-online relies on NetworkManager being properly configured and running. If NetworkManager is not running or is misconfigured, nm-online may not provide accurate results. It's also important to note that network reachability is a complex issue, and nm-online provides only one perspective based on NetworkManager's understanding.
EXIT STATUS
nm-online returns 0 if the system is online according to NetworkManager, and a non-zero value otherwise.
SEE ALSO
nmcli(1), NetworkManager(8)