…and you use the default Network Manager (whether KDE, GNOME, or Xfce).
How do you get it to work correctly?
By “work correctly” I mean that the service should not run when a network connection is unavailable.
However, there seems to be a strange definition for what constitutes “online”.
For example, when I am connected via wired or wireless in my KDE Network Manager, these are the following outputs, which are correct:
The default dependencies for network-online.target:
systemctl list-dependencies network-online.target INT ✘
network-online.target
● └─NetworkManager-wait-online.service
network-online.target status:
systemctl status network-online.target ✔
● network-online.target - Network is Online
Loaded: loaded (/usr/lib/systemd/system/network-online.target; static)
Active: active since Sun 2021-09-19 11:38:53 BRT; 3 days ago
NetworkManager-wait-online.service status:
systemctl status NetworkManager-wait-online.service ✔
● NetworkManager-wait-online.service - Network Manager Wait Online
Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; enabled; vendor preset: disabled)
Active: active (exited) since Sun 2021-09-19 11:38:53 BRT; 3 days ago
So far, so good, yes? There’s just one problem. Even after disconnecting from the network (confirmed by being unable to ping neither a local address nor remote website), network-online.target continues to show that I am online.
This is a problem, because custom services that depend on a truthful network status will immediaely attempt to run and fail (rather than wait 30 seconds for the network to be “online”) which I confirmed by checking the logs, even though I declared them with Wants=network-online.target and After=network-online.target
The most I could gather from my limited research capability is that this is due to the lack of consensus of what it means to be “online”. ![]()
Some would argue you need to be able ping a remote website, others argue that the interface must be up, others argue that you’ve been assigned a DHCP address, others argue if you can ping a local network device, etc.
Does anyone know how to instruct systemd (when using Network Manager) that “online” is only acceptable when a remote website can be reached?
To reiterate, when I am absolutely offline, I still get this result when checking the status of network-online.target:
● network-online.target - Network is Online
Loaded: loaded (/usr/lib/systemd/system/network-online.target; static)
Active: active since Sun 2021-09-19 11:38:53 BRT; 3 days ago
For reference, this unsolved problem similarly describes what I am facing:
How can I run a systemd service after network link has been established?

I’ll play around and report back.