Linux test TCP/UDP port connectivity with nc command

TCP

# 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!

UDP

# 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!

Bouns

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.

Leave a Reply

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