Check the connectivity of the TCP/UDP port on a Linux server

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.