I agree - the definition of network online is a very floating description and the correct answer depends on what you are trying to achieve.
Over the years there have been a lot of questions asking - what it that apollo.archlinux.org I am seeing in my wireshark logs? It was the NetworkManager connectivity check.
The page linked by @xabbu is quite informative - thank you @xabbu
This is what NetworkManager-wait-online.service is doing using the nm-online command.
This was not correct - what I thought I was saying was that NetworkManager runs a regular check which has surprised many users.
$ cat /usr/lib/NetworkManager/conf.d/20-connectivity.conf
[connectivity]
uri=http://ping.manjaro.org/check_network_status.txt
The successful run of the command reveals four thing
- your nic is up and running
- your dns is up and running
- your router is up and running
- the target is accessible using name resolution
But as you have noted - the network-online is a generic concept and you need to handle the actual situation in your script code.
In the simplest form - use -x and grep for [online].
nm-online -x