EN: is „ping” the only tool used for checking connectivity? 🙁 – blogMigration

So again this week a fellow IT guy approached me and said „the service does not respond to ping so it is probably dead and we have some errors on our dashboard. Should we restart the server?” – sad thing: he had a snr position

What ping tool does:

it uses icmp protocol to check connectivity.
it uses udp protocol to resolve host name to ip
it measures round trip times
oftenly wise administrators block incoming ICMP traffic to servers

What ping tool does not do:

Does not work over TCP protocol (ICMP is not close to HTTP)
Does not determine if you have internet access
Does not state what DNS servers you are using

So in order to check if the service is working (or not) one colud follow:

nslookup # determines DNS servers used – in example if using google’s 8.8.8.8 it will not resolve internal names to internal IPs in LAN.

ping bbc.com # it checks RTT + if name is resolved to ip by the way

telnet bbc.com 80 # it checks if under the ip address pointed by bbc.com port 80 is open for communication. Once connection is open via telnet you can type:

GET / HTTP/1.1

Host:bbc.com

and a few enters (carrige returns)

if you get a 200 http status code or 400 or 500 this means that the server responded to your http request over plaintext http protocol (so no only connection works but also the www service returns some data).

What if one does not have telnet on a windows machine?

ControlPanel > AddWindowsFeatures> Pick TelnetClient > OK> Press Start button and type cmd

What if one does not have telnet not admin rights on a windows machine?

Enter powerShell or powerShellISE and type:

Test-NetConnection -ComputerName „rt.com” -Port 80 -InformationLevel „Detailed”

Alternatively having local admin rights you may install telnet via powerShell by running it as Administrator / with elevated privilages and typing:

Install-WindowsFeature -name Telnet-Client

On windows machines one may also check the http status code returned by the website / service by typing:

If ( [System.Net.WebRequest]::Create(‚http://google.com’).GetResponse() -eq 200) {
Write-Host ‚it werks’
} Else {
Write-Host ‚Houston we have a problem’
}

On linux systems similar functionality may be achieved using telnet, wget, curl and various other ways:

openssl s_client -connect google.pl:443 # you also get certificate details

if curl -s –head –request GET https://google.com | grep „200 OK” > /dev/null; then
echo ‚it werks’
else
echo ‚Houston we have a problem’
fi

wget –spider -S „http://google.pl” 2>&1 | grep „HTTP/” | awk ‚{print $2}’

or to simply test if port open:

telnet aa.com 80

or without telnet

(echo > /dev/tcp/localhost/22) >/dev/null 2>&1 && echo ‚it werks’ || echo ‚Houston we have a problem’

Cool?


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *