October 5, 2015 by Andrew Fore
One of the tools that I use on a regular basis to test network connectivity updates is the “z” option of netcat. Apparently when RedHat rolled out the latest version of their distribution of RedHat Enterprise Linux (RHEL) they decided to move to using the nmap-ncat package instead of the nc package. The command options a very different.
So when attempting to test single port like I would have under previous releases I now use the following syntax:
# echo | nc -w1 $host $port >/dev/null 2>&1 ;echo $?
If the result that is returned is a zero then you have successfully connected to the remote host on the desired port. This also applies to CentOS 7 since it is a “clone” or copyleft port of the RHEL7 binaries.
Categories Uncategorized Tags CentOS, Linux, Tips n Tricks, Uncategorized 1 Comment