Score:1

Issue while checking network connectivity using nmcli in ubuntu 18.04

cn flag

I am using "nmcli networking connectivity" command to know the connectivity of my wifi connection. After establishing the connection with a wifi & if I see that it has no internet connection then "nmcli networking connectivity" show "limited" which is quite natural. But when that wifi connection got internet connection back and then if I run "nmcli networking connectivity" then also I am getting "limited" instead of "full". I have rescanned the network and also wait for few seconds and then run the command but I got the same result.(i.e. limited)

But if I reconnect with the wifi by running "nmcli device wifi connect [SSID] password [wap_key]" & then try to see the network connectivity then I got "full"

So, that means every time I want to check the the network connectivity I have to reconnect with the wifi (which is not desired). Is it so?

If not then please tell me suitable method (linux command, not via gui or not via ping, system command is more acceptable) to check whether my wifi has internet access or not. [any c/c++ code is also acceptable]

Score:0
br flag

I think you just missed the argument check. This argument rechecks the connectivity.

    nmcli networking connectivity check

From man pages

   connectivity [check]
       Get network connectivity state. The optional check argument tells NetworkManager to
       re-check the connectivity, else the most recent known connectivity state is displayed
       without re-checking.

       Possible states are:

       none
           the host is not connected to any network.

       portal
           the host is behind a captive portal and cannot reach the full Internet.

       limited
           the host is connected to a network, but it has no access to the Internet.

       full
           the host is connected to a network and has full access to the Internet.

       unknown
           the connectivity status cannot be found out.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.