Troubleshooting internet connection problems

Posted on 2011-10-11
Last Modified: 2012-05-12

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??
Question by:jonathanduane2010
    LVL 4

    Expert Comment

    by:Christopher Raymond Mendoza
    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)?
    LVL 35

    Expert Comment

    by:Ernie Beek
    LVL 10

    Accepted Solution

    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....

    @echo off
    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 > 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!
    LVL 14

    Expert Comment

    by:Rob Miners
    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
    ping.exe | FIND "TTL=" > NUL
    ECHO You have %CONNECT% active connection to the Internet %DATE% %TIME% >> C:\pingtest.txt
    goto CARD

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

    :: Checking connection to Modem/Router
    SET MODEM=is
    ping.exe | FIND "TTL=" > NUL
    ECHO Your Modem %MODEM% responding %DATE% %TIME% >> C:\pingtest.txt

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now