As you can see, the connection succeeded. This means that port 22 is open. If the connection fails, then you will get an error message of āfailed: Connection refusedā
In the above command, we also used different options. Letās list them below.
z: zero-I/O mode which is used for scanning v: for verbose output w10: timeout wait seconds
nmap
Letās see the nmap syntax below.
nmap [-options] [IP or Hostname][-p][PortNumber]
As you can see, its syntax matches that of the nc command. Letās run it to get a better understanding.
nmap192.168.0.1-p22
If the port is closed, then it will show status is closed
telnet
The syntax of the command is as below.
If the connection fails, then the port is not open, and you will get the following output.
echo > /dev/tcp/...
The syntax of the command is as below
or
netstat -tuplen
It will output the whole list of the IP addresses. The entries that have āListenā in the āStateā column are the open ports.