• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

Troubleshooting internet connection problems

hi,

i was wondering if there was a script i can run that will help me determine if a machine keeps losing connection to the internet?

I was thinking of just running a ping to google with -t and then outputting it to a file?

I was wondering how do i put the switch in to output it to a txt file ? and i was wondering is there anyway i could just output the timeouts??
0
jonathanduane2010
Asked:
jonathanduane2010
1 Solution
 
Christopher Raymond MendozaCommented:
Hello, there are various methods that can be used, largely depending on what hardware and software you are using. Is your computer directly connected to the internet, or through a router? What OS are you using (I am assuming windows)?
0
 
Ernie BeekCommented:
0
 
CSIPComputingCommented:
Unfortunately, pinging google alone won't be able to tell you if the computer is losing a connection to the internet, if you have a faulty network port, or if your router is having problems.

I'd suggest you need to also ping the internal interface of the router (as a minimum) to check that you are still connected to the network.

However, a plain PING won't include time/date stamps, which would be critical to determining what happened and when.

However, to answer your original question, you can write a batch file which will run as a scheduled job, which you can set to end if it runs for more than 24 hours, and trigger it to start every day.

If you're then clever with how you output the results, you get a daily log of your ping results.

You can then use "Find" to find failures....

e.g.
@echo off
CLS
REM Create a LogName variable which contains todays date
set LogName=%date%
REM Now make it usable for a filename (Swap / for - )
set LogName=%LogName:/=-%

Echo Pinging Google...
ping -t www.google.co.uk > C:\Logfiles\%LogName%.log


You can then use FIND as follows:

find "Unreachable" < nn-nn-nnnn.log
(where nn-nn-nnnn.log) is the day you're interested in.

You could of course automate the find as well, and output that to a file too!

Hope that helps!
0
 
Rob MinersCommented:
This will give you basic information for your main connections, check your NIC and give you a starting place to diagnose from. Using this eXample will keep the file size to a minimum: You will need to change the IP Address of your Modem/Routers Default Gateway.

sAmple of pingtest.txt
Your NetWork Card is good   Wed 12/10/2011  8:42:46.87
Your Modem is  responding Wed 12/10/2011  8:42:49.91
You have an  active connection to the Internet Wed 12/10/2011  8:42:52.99

Thanks to Rob Vanderwoude for the refresher
=========================================================================
@echo off
:: Pinging Google
if not exist c:\pingtest.txt echo Network Connections > C:\pingtest.txt
:BEGIN
SET CONNECT=an
ping.exe 74.125.237.81 | FIND "TTL=" > NUL
IF ERRORLEVEL 1 SET CONNECT=NO
ECHO You have %CONNECT% active connection to the Internet %DATE% %TIME% >> C:\pingtest.txt
goto CARD

:: Checking Network Card
:CARD
SET NIC=good
ping.exe 127.0.0.1 | FIND "TTL=" > NUL
IF ERRORLEVEL 1 SET NIC=BAD
ECHO Your NetWork Card is %NIC%  %DATE% %TIME% >> C:\pingtest.txt
goto Rout

:: Checking connection to Modem/Router
:Rout
SET MODEM=is
ping.exe 192.168.1.1 | FIND "TTL=" > NUL
IF ERRORLEVEL 1 SET MODEM=isnt
ECHO Your Modem %MODEM% responding %DATE% %TIME% >> C:\pingtest.txt
GOTO BEGIN
=========================================================================
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now