LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-01-2020, 12:37 PM   #1
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Rep: Reputation: Disabled
terminal tool to check internet connection when disconnection


Hii

I would like to know is there any terminal tool that i can use to run in terminal constantly be it internet is ok or internet got disconnected ?

Recently i have got internet disconnection issue with my service provider. I often found out my router reset itself and it is trying to connect or something.. hence lost lan and internet. sometime got lan but no internet.

I tried these 2 cli tools when internet disconnected:
ping www.google.com
and
Mtr www.google.com

but, these tools can't help me to know when internet is again connected .. because i saw router signal Indicator is normal, but both ping and mtr keeps showing as not connected... until i cancel and rerun the command.. then it shows it is connected..

if i need to rerun when internet is back to normal, then, those tools are useless in this case.

Is there such tool ?

thx
 
Old 12-01-2020, 01:24 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Ping works.
You can ping a domain, then you know that both internet and name resolution work.
You can ping a numerical IP address, then you know that internet works.

It is entirely possible for your router to be connected to the internet, but not your computer.
It can have dozens of reasons.
 
Old 12-01-2020, 02:14 PM   #3
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
Ping works.
You can ping a domain, then you know that both internet and name resolution work.
You can ping a numerical IP address, then you know that internet works.

It is entirely possible for your router to be connected to the internet, but not your computer.
It can have dozens of reasons.
I am sure ping does not work in this scenario.
I have tried many time in many days when my internet got disconnected;

When my internet got disconnected, i can see router blinking
Then i run "ping www.google.com"
it just shows "failure in name resolution." **this is when router is still initializing itself**
it shows "64 bytes from _gateway (192.168.0.1) ... **this is when the router lan has established, but internet connection is not establish yet***
and it just keeps showing "64 bytes from _gateway (192.168.0.1) ..." this for ever.. **even after internet connection has established for hours. **
until i pressed "ctrl-c" and retype "ping www.google.com", then only it will shows " 64 bytes from fra16s12-in-x04.1e100.net...."

Please look at the attached photo of the ping.. the "upper portion" of ping was done when the router resetting. I forgot about the ping.. and you can see, the icmp_seq was 8934.... , it still shows "ping gateway" only even i had have internet for long time already.

the "lower portion " is the when i redo ping after internet has already established.

See the different..

Click image for larger version

Name:	qcjm0FW.png
Views:	19
Size:	204.3 KB
ID:	34728

mtr still showing "gateway" ... only even this very second.. because i have not ctrl-c it and redo mtr.

hence these 2 software can't inform me when internet has established.

sometime i am busy typing,.. i won't realize if internet connection has established or not (when i am busy typing)... hence i want a simple package will tell me if internet has being established instead of just lan has being establish..

Last edited by andrewysk; 12-01-2020 at 02:16 PM.
 
Old 12-01-2020, 02:57 PM   #4
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
When your router disconnects from the internet (for any reason) you will not get name resolution nor any other communication such as ping responses.

A constantly running process may get locked into one response and not be able to see changes, although ping, if working before the link dies, should recover since it already knows the IP it is sending to. If used when the link is already broken you cannot rely on the response as you can tell. Pinging with a known IP address on the internet would avoid the invalid response from your router. It either works or the packet is lost.

The real issue seems to be your provider is unreliable and that cannnot be fixed at your end. One other thing that may be in play is power to your router, or a bad cable connection. The provider should fix the cable but you are responsible for the power. You should be calling them and complaining every time the link goes down instead of trying to work around it. With enough trouble calls they should actually fix it, and if not then you should get a different provider.

.
 
Old 12-02-2020, 01:13 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I'd still try to ping a numerical IP to make 100% sure it's a DNS issue.
 
Old 12-02-2020, 04:05 PM   #6
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Err.. is there difference between ping nummeric ip vs ping dns name such (www.google.com ) ?
 
Old 12-02-2020, 06:28 PM   #7
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by andrewysk View Post
Err.. is there difference between ping nummeric ip vs ping dns name such (www.google.com ) ?
Yes, a big difference.
Pinging a numeric IP goes directly to the address.
Pinging a URL requires that dns has to be called to resolve the name and obtain the IP before the ping can be sent.

Once the address is available then the ping part is the same.
 
1 members found this post helpful.
Old 12-02-2020, 08:22 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,321
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
You can also ping your router's ip address to check whether the connection to the router is active. If you can ping your router, but not the Big Wide World, the issue is definitely with your internet connection, and not within your local network.

Another useful command in traceroute. It can tell where the connection is going bad. See man traceroute for details.

Building on what computersavvy said above, I've had experiences in which I could ping 8.8.8.8 (which is a Google IP), but could not ping google.com. That tells me that I was experiencing DNS resolution issues (the issues were out of my control, but were quickly resolved).

You may find this article helpful: http://www.linuxandubuntu.com/home/1...rk-diagnostics
 
1 members found this post helpful.
Old 12-02-2020, 08:48 PM   #9
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,173

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
running a continuations ping to someone else's server may get your IP banned by the server. If you can, pick a server you own outside your network.
 
Old 12-02-2020, 10:13 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Quote:
A constantly running process may get locked into one response and not be able to see changes,
For a situation like this, I have a tiny bash script that uses the -c (count) option for ping.
I don't have the code handy right now, but basically its an infinite loop that calls 'ping -c3 <somewhere>'.
This means ping only tries 3 times then quits, so each invocation is brand new and gets around the 'stuck/hung syndrome.

HTH


PS as noted above, you can annoy people if you overuse it, so my loop checks the rtn code and if it sees '0'
Code:
if [[ $? -eq 0 ]]
then it quits the loop.
 
Old 12-03-2020, 09:45 AM   #11
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,173

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
Found the info the code I was using a few years ago to log network issues. http://www.ibiblio.org/icpld/

It uses pings to check for a network connection and logs when it drops and when it returns. I used our webserver hosted elsewhere to ping from the office I was at and the fallback was google.com. Once the ping to the webserver stopped, then it tried to ping google and when that failed it would register the network as down. I think it pinged both until the network returned, then it would fall back to just the primary ping of the webserver.

Last edited by uteck; 12-03-2020 at 09:45 AM. Reason: typo
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection/disconnection problems with wpa_supplicant and hostapd when using WPA2 enc wallamit Linux - Wireless Networking 0 01-23-2012 06:05 AM
[SOLVED] Linux 3.0 Internet Disconnection Konphine Slackware 7 07-24-2011 01:22 PM
Problem on Internet disconnection satimis Linux - Networking 25 10-08-2007 10:31 PM
Issue on Repeated USB Device Connection/Disconnection. jcaga Linux - Hardware 2 04-11-2007 05:24 AM
[SOLVED] Internet disconnection using Suse 9.3 enrico_dvchp Linux - Newbie 3 08-17-2006 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration