8

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.

4
  • If DNS is the issue, you could always ping google at 74.125.91.105
    – Daniel
    May 27, 2011 at 23:23
  • At Android it is showed (grey icon if connected but no internet, green icon if internet is ok, no icon if no connection). Maybe we can do something like these with some script.
    – desgua
    May 30, 2011 at 18:47
  • @desgua, exactly what I'm looking for. But there isn't any obvious way to figure out the status of internet in the first place. If you know how to, please post an answer.
    – Oxwivi
    May 30, 2011 at 19:09
  • Filed under "Ubuntu is so easy to use!" Aug 16, 2019 at 20:20

5 Answers 5

4

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.

6
  • By neigbor, are you referring to some other machine on the system?
    – Oxwivi
    Jun 1, 2011 at 3:48
  • a "neighbor" is a machine attached to the local machine by a local link- that is, it takes only 1 hop to get to the machines listed by 'ip neigh show'
    – koanhead
    Jun 1, 2011 at 8:22
  • Oops, I meant ither machine on the network.
    – Oxwivi
    Jun 1, 2011 at 9:13
  • Yes, that's what it implies, although "neighbor-ness" is actually a point-to-point link such as you should have with your AP. Note that this is different from "Network Neighborhood" as in Windows or Samba. If you use "ip neigh show" and there's only one local link, then that's your AP. If you don't have any or none show up as "REACHABLE" then you have no local link.
    – koanhead
    Jun 3, 2011 at 16:02
  • So I tried your commands in the situation described in this question and looks like it doesn't help. The first two commands verify proper network connection the same as nm-applet shows in the panel. So it does not allow me to know if the local connection is refusing to internet access.
    – Oxwivi
    Jun 3, 2011 at 16:17
2

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!

7
  • Updated question.
    – Oxwivi
    May 31, 2011 at 14:57
  • regarding your update, I believe ifconfig and iwconfig are the commands you want. iwconfig is very obvious to use, but is only for wireless. With ifconfig, you want to see if you have an ip address, which will be listed like "inet addr:xxx.xxx.xxx.xxx" on the second line. I'm repeating myself a bit. I will try to clean up my answer.
    – user1974
    Jun 1, 2011 at 2:16
  • 1
    ok, I've updated my answer. Honestly, if would be nicer if network manager just gave you the information you are looking for. You could try filing a bug report in that regard. That's all I got. I know it isn't exactly what you are looking for, since it is all terminal commands. Best of luck!
    – user1974
    Jun 1, 2011 at 2:41
  • also, I have been told that 'ifconfig' gives unreliable results with modern kernels, which is why my answer relies upon iproute2. afaik there is unfortunately no 'iproute2' set of options that will do what 'iwconfig' does.
    – koanhead
    Jun 1, 2011 at 8:28
  • @koanhead I'm curious what the issue is. Do you know? The first result of a google search said that ifconfig is limited on 32bit kernels to 32bit numbers for some of the statistics. Not a big deal IMHO
    – user1974
    Jun 2, 2011 at 22:23
0

I use a small utility (in the repository) called wmnetmon. Its CPU friendly and very customizable. It uses very little screen space, or you can dock it to the panel with the Swallower Meta-Applet. It might look like a lot of work setting it up, but its not that hard. I am including my configuration at the end to get you started. My setup monitors my LAN and Internet Connectivity. I am using 10.04, not sure if it works on 11.04.

wmnetmon
In the panel or on the Desktop

Description - A dockapp which will show an LED for every monitored service. Green LEDs indicate that the service is up and running, as opposed to a blinking Red LED, which indicates that the service isn't responding correctly.

Options

wmnetmon [-d] [-t ] [-y ] [-r ] [-c ] [-h]

-h Show summary of options.

-d turns on debugmode

-c use the specified configuration file instead $HOME/.wmnetmonrc

-t : specifies the poll time in seconds. Default is 30 seconds

-y : specifies amount of time to wait for a reply before turning the yellow led on. Default is 60 seconds

-r : same as above for the red (flashing) led. Default is 200 seconds.

Edit the .wmnetmonrc (in the user directory) and start wmnetmon. The leds will shortly turn green for hosts/services that do respond and turn off or start blinking in red for those who do not. You can specify whether it will blink or turn off. In the former case a command will be executed if you configure it on the rc file. This is great for playing sound. Whenever you point at some specific led, the corresponding description will appear on the top of the app. If you right-click on it the host/service will become muted, and no command will be executed when that particular system fails. Also you can configure it in the rc file to stop monitoring it when it is muted. If you do so, the led will turn off, otherwise it will become purple or blue, notifying you if the system is working or not.

My Startup Options are set to (edit as needed).........

wmnetmon -t 10 -y 2 -r 2

My Configuration (edit as needed).........

# WMNetMonrc for Version 0.1c/d
#
# Please change this file and copy it to your home directory and name it
# .wmnetmonrc
#
#
# D line
# Format - D:[w|d][i|m]
# Example - D:dm
#  - This line specifies the default behaviour of wmnetmonrc
#    The flags are:
#
#    w -> Warn when hosts/services stop responding. This is the default
#         behaviour. The led will turn red and flash, and (if specified)
#         an  external command will be executed.
#
#    d -> Don't warn. Led will be off if host/service stops responding.
#
#    i -> Ignore host/service (stop monitoring it) when muted. The led 
#         will be blue.
#
#    m -> Mute host/service (don't execute external program) but keep on
#         monitoring it. The led will be blue if the host/service 
#         responds or purple if it does not. This is the default.
#
D:dm
#
#
# P Line
# Format: P:[<path>]<command> [<args>]
# Example: P:/usr/bin/play
#  - This line specifies the program that will be run on special events.
#    * ONE LAST PARAMETER will be passed on to this program according to
#    event type, and will be specified in other configuration lines.
#
# P:/usr/bin/play
#
# S Line
# Format: S:<argument>
# Example: S:Siren.wav
#  - This is the argument will be passed to the program specified when 
#    hosts/services stop responding. 
#
# S:Siren.wav
#
#
# H Line
# Format: H:[tcp|udp/<servicename/portnumber>@]<host_ip_or_fqdn>:<hostname>[:flags]
# Examples: H:127.0.0.1:localhost:id
#           H:tcp/[email protected]:sendmain on localhost:w
#           H:udp/[email protected]:quake time
#       H:foo.bar.net:foobar
#
#
#  - This is the most important line. Just add the hosts/services you 
#    want to monitor. The flags are the same as for D line.
H:192.168.0.1:dsl:wi
H:192.168.10.1:router:wi
H:192.168.10.2:test:
H:192.168.10.100:localhost:
H:192.168.10.111:dave:wi
H:192.168.10.112:family:wi
H:192.168.10.113:media1:wi
H:192.168.10.114:media2:wi
H:192.168.10.115:n770a:wi
H:192.168.10.116:n770b:wi
H:192.168.10.117:localhost:
H:192.168.10.118:localhost:
H:192.168.10.119:localhost:
H:192.168.10.120:localhost:
H:8.8.8.8:google:wi
H:8.8.4.4:google:wi
#
# end
4
  • Can you explain how it works, and why it would help my particular issue?
    – Oxwivi
    Jun 12, 2011 at 15:05
  • On my setup (See Screenshot) the first "LED" is my DSL modem, the second is my Router, the last 2 are Google's DNS servers (the Internet), The rest are various IP addresses on my LAN. So if my Internet goes down, only the last 2 will blink red. If my DSL Modem goes down, the 1st and last 2 will blink red. If any of my LAN devices go down, the corresponding LED will turn red. If my Router goes down, everything will go red. If you hold the mouse over one of the LED's, the description of that device will show up. I have DHCP on all devices turned off, and static IP's assigned. Easy to diagnose.
    – deleted
    Jun 12, 2011 at 21:55
  • How it works is most likely by a ping. Even though you don't want to use pinging to find the problem, I think it is the easiest way to diagnose a network.
    – deleted
    Jun 12, 2011 at 22:01
  • Also (but unrelated to the O.P.) my configuration is set so authorized IP's are blue, and unauthorized IP's on my LAN will be green. Its lets me know if someone gets into my Wireless network.
    – deleted
    Jun 12, 2011 at 22:11
-1

What Ubuntu version are you using? On Meerkat and Lynx there is NetworkManager Applet that shows up at the top panel, right side where the indicators are at. It should be there by default. I have not installed any version as mentioned that didn't include the network applet.

If you can't find it there, you must've removed it by mistake. You can add it again by right clicking on the top panel and selecting Add to Panel where you will find a list of applets to choose from. Select the appropriate one.

Now depending on your icon theme, the indicating icon that there is no connection varies. Try to click on the applet and select disconnect, see what happens. When there is no Internet connection, it will show that icon and will indicate with a message that your connection is lost.

1
  • To avoid answer like yours I did mention "if there's no internet connectivity for whatever reason and the connection to the network is perfectly fine". I am talking about the situation when connection on the wire or the Wi-Fi network is normal, but no internet traffic.
    – Oxwivi
    Apr 29, 2011 at 13:23
-1

I'm aware of the observation "please no ping to x website", and the question "what ways are there". But how we can say if the internet is available if we doesn't test it? (That is the question asked, I know). Well this is one way, and I will add others ways as soon as (and if) I can find.

We can make a script that will show you (at a terminal) the internet connectivity state pinging some reliable server. I need to research how to make it a panel notification.

The script:

#!/bin/bash
#
# This script will check if you 
# have access to internet
#
# by desgua
#
#######################################
while [ "$var1" != "end" ]
do
pingtime=$(ping -w 1 8.8.8.8 | grep ttl)
if [ "$pingtime" = "" ] 
then 
   pingtimetwo=$(ping -w 1 74.125.91.105 | grep ttl) 
   if [ "$pingtimetwo" = "" ] 
   then 
       clear ; echo 'down'
   else
       clear ; echo 'up' 
   fi 
else
    clear ; echo 'up' 
fi
sleep 2
done 
1
  • Updated question.
    – Oxwivi
    May 31, 2011 at 14:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .