Checking ports using Bash

Ping

When we want to check whether a host is reachable (at all), we can use the ping command:

It sends ICMP Echo Requests to the given host and reports how many packages are received and responded to. The option -c can be used to set how many requests are sent.

Checking specific endpoints

A disadvantage of ping is that we cannot configure a specific endpoint (= host + port) to ping. More advanced tools offer alternatives. The following command pings the FTP port of www.roland-kluge.de:

nping belongs to the nmap package. On Ubuntu, nmap can be installed as follows: sudo apt-get install nmap .

Another tool is  Netcat. The advantage of nc is that the error code indicates whether the endpoint was pinged successfully, making it useful for checking endpoint availability in scripts.

On Ubuntu, Netcat can be installed as follows: sudo apt-get install netcat .

References

  • [1] Nmap project site
  • [2] Netcat project site

Leave a Reply

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

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box