Telnet and NC are general tools for testing port connectivity.
Telnet can test the connectivity of the TCP port.
NC can test the connectivity of TCP and UDP ports.
Make sure that Telnet and NC tools are installed # Yum install nc# yum install Telnet
To test the connectivity of the TCP port:
Syntax: Telnet
The following are examples of connectivity successes:
[[Email protected] ~]# telnet 192.168.56.11 22Trying 192.168.56.11...Connected to 192.168.56.11.Escape character is ' ^] '. Ssh-2.0-openssh_5.3connection closed by foreign host.
The following are examples of unsuccessful connectivity:
[[Email protected] ~]# telnet 192.168.56.12 22Trying 192.168.56.12...telnet:connect to address 192.168.56.12:no route to Host
Use the NC command to test the connectivity of the TCP port:
Syntax: nc-z-v The following are examples of connectivity successes:
[Email protected] ~]# nc-z-v 192.168.56.11 22Connection to 192.168.56.11 Port [Tcp/ssh] succeeded!
The following are examples of unsuccessful connectivity:
[[email protected] ~]# nc-z-v 192.168.56.12 22nc:connect to 192.168.56.12 port (TCP) Failed:no route to host
Use the NC command to test the connectivity of UDP ports:
Syntax: nc-z-v-u The following are examples of connectivity successes:
[Email protected] ~]# nc-z-v-u 192.168.56.12 123 Connection to 192.168.56.12 123 port [UDP/NTP] succeeded!
NC command syntax
NC [-hlnruz][-g< Gateway ......>][-g< number of pointers >][-i< delay seconds to kill >][-o< output file >][-p< communication port >][-s< Source location >][- V ...] [-w< timeout number of seconds;] [Host name] []
NC Command Parameter Interpretation
-N directly specifies the IP address, not through the domain name resolution
-V Show Instruction execution process
-U using UDP protocol
-Z uses 0 input/output mode, only when scanning communication ports
This article from "Hyun-dimensional" blog, reproduced please contact the author!
Check the connectivity of the TCP/UDP port on a Linux server