Instantly share code, notes, and snippets.

Embed
What would you like to do?
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