Last Updated on
# nc -z -v [hostname or IP address] [port number]
nc -z -v 192.168.100.1 443 Connection to 192.168.100.1 443 port [tcp/https] succeeded!
# nc -z -v -u [hostname or IP address] [port number]
# nc -z -v -u 192.168.100.1 123 Connection to 192.168.100.1 123 port [udp/ntp] succeeded!
We can also test TCP port with telnet command
telnet [hostname or IP address] [port number]
# telnet 192.168.100.1 443 Trying 192.168.100.1… Connected to 192.168.100.1. Escape character is '^]'.
If return “Connected to xxx.xxx.xxx.xxx”, it means the port is open and functional
If return “Trying xxx.xxx.xxx.xxx…”, it means the port is closed or not accessible.