Detect internet connection
On Windows, if there's no internet connectivity for whatever reason and the connection to the network is perfectly fine, a small icon shows on the network icon in the notification area. Is there any way to do the same on Ubuntu?
Even that is not necessary, I just want to know what ways are there to find if the internet connection is lost or not.
No ping to x website please, I've faced a few instances of DNS outage and ping failure can be due to DNS down time, not internet connectivity.
UPDATE
Thanks for all those interesting answers. My actual aim of this question was to know if there was a method to know the status of my connection at the local level (connection between the machine and AP), which is why I said no ping to x website please. The LAN private address that was mentioned by Alain is something that comes close. If I can diagnose that, I can rule out AP/network issues, then move onto diagnosing the actual connection to my ISP.
The command ip link show
shows the status of available interfaces. At least one of the interfaces on needs be listed as UP in order for you to have any connectivity at all.
The command ip neigh show
shows local link state, like this:
192.168.0.1 dev eth0 lladdr 00:15:e9:ec:cc:80 REACHABLE
You need at least one REACHABLE to have network access.
The command ip addr show
shows all interfaces and their IP addresses.
Once you have a local IP address and a neighbor's IP address, you can then use ping or another tool to verify local IP connectivity.
I think the short answer you are looking for is the command dig
, but let me tell you all the commands I use, FWIW. My experience is in debugging a simple home network setup, with my computer, a wireless router, and a cable modem.
First I start with dig website
, which does a DNS lookup.
LAN and DHCP
If dig times out, then I likely don't have a proper connection to the LAN. For wired connections, I just check for the blinking lights on the modem. I don't know of a command that checks for that. For wireless connections, I use iwconfig
and check the ESSID value, making sure that it is set to my network.
Once you have the hardware part checked out, the other thing to check for LAN connectivity is DHCP. I check ifconfig
(which is similar to the windows ipconfig) to see if I have an ip address or not. eth0 is your wired connection, and wlan0 is your wireless connection. Look at the second line for the value labeled "inet addr". That is the ip address. Having an ip address of the form 192.168.x.x or 10.0.x.x means I am connected to my LAN, and I am getting an ip address from the router.
DNS and Internet If dig comes back with a response, but it is empty, then I am probably connected to my wireless router (ie, the LAN), but there is a problem with my internet connection (ie, the modem). I will log into my router's web interface and try to debug the issue there. Or, I will plug in my computer directly to the modem, and recheck the commands above (dig and ifconfig. Note, the ip address should not be as described above)
Connected but still not working Lastly, if dig returns at least one ip address (most small websites have a single ip, where as big sites like google have multiple ips), then I figure I am at least connected and DNS is working. The problem must exist on the internet somewhere.
I will then use mtr website
as a more comprehensive ping. Mtr is the same as the windows tracert command; it pings the website along with all intermediate nodes and displays it in a real time visual fashion on the terminal, thus showing me where on the internet I am having trouble.
Hope that is useful!