Skip to content

Instantly share code, notes, and snippets.

@ahadsheriff
Last active March 10, 2017 00:19
Show Gist options
  • Save ahadsheriff/524345273652cc3ab0a437cd21974a7d to your computer and use it in GitHub Desktop.
Save ahadsheriff/524345273652cc3ab0a437cd21974a7d to your computer and use it in GitHub Desktop.
Ping script to test local, remote, and DNS connectivity, written in bash.
@ echo off
echo Testing local connectivity
ping 192.168.1.102 > nul
if errorlevel 1 goto :ERRORLocal
goto :LocalSuccess
:TRYRemote
echo Testing remote connectivity
ping 8.8.8.8 > nul
if errorlevel 1 goto :ERRORRemote
goto :RemoteSuccess
:TRYDNS
echo Testing DNS
ping www.google.com > nul
if errorlevel 1 goto :ERRORDNS
goto :DNSSuccess
:LocalSuccess
echo Test Successful
goto :TRYRemote
:RemoteSuccess
echo Test Successful
goto :TRYDNS
:DNSSuccess
echo Test Successful
goto :END
:ERRORLocal
echo Local Ping test failed!
goto :TRYRemote
:ERRORRemote
echo Remote Ping test failed!
goto :TRYDNS
:ERRORDNS
echo DNS test failed!
goto :END
:END
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment