Methods for testing TCP and UDP ports

Source: Internet
Author: User


Methods for testing TCP and UDP ports

The following is an example of a Linux platform that describes methods for testing TCP and UDP ports.
There are two commands that can be used to test the port, one is Telnet, the other is NC, but telnet can only be used to test the TCP port, and the NC can be used to test the TCP port and also to test the UDP port.

"Use of the telnet command"
Telnet IP Port
For example:
[root@localhost]# telnet 192.168.0.181 20060
Trying 192.168.0.181 ...
Connected to 192.168.0.181.
Escape character is ' ^] '.
Quit//Enter quit and return to exit Telnet.
Connection closed by foreign host.
[root@localhost]#

"Usage of NC Commands"
1. Test TCP port
Nc-vz IP Port
For example:
[root@localhost]# nc-vz 192.168.0.181 20060
Connection to 192.168.0.181 20060 port [tcp/*] succeeded!
[root@localhost]#
2. Test UDP port
Nc-vuz IP Port

Give an example to explain

The IP of Windows is 192.168.0.3,linux IP is 192.168.0.32.
Run the TCP/UDP debugging tool on Windows, as shown in the following illustration.


When the port number is not created on the Debugging Tools 34567 Service, there is no output from Linux to perform NC commands as follows. As follows:
[root@localhost]# Nc-vuz 192.168.0.3 34567
[root@localhost]#//performs NC command without any information output.
After you create a port number of 34567 service on the debugging tool, there is "succeeded" information output after Linux executes the NC command. As follows:


[root@localhost]# Nc-vuz 192.168.0.3 34567
Connection to 192.168.0.3 34567 port [udp/*] succeeded!
[root@localhost]#

---notice---
When you perform an NC command, sometimes you can also output "succeeded" information by casually writing a host name and a valid port number, as follows:
[root@localhost]# Nc-vuz srtsrtseggg 61357
Connection to SRTSRTSEGGG 61357 port [udp/*] succeeded!
[root@localhost]#
That is because the DNS server has pollution (or advertising insertion), for any non-existent domain name will be given to resolve IP. This can be checked with the wget command, as follows:
[root@localhost]# wget--spider SRTSRTSEGGG
Spider mode enabled. Check if remote file exists.
--2016-06-08 01:59:04--http://srtsrtseggg/
Resolving srtsrtseggg ... 123.129.254.17
Connecting to srtsrtseggg|123.129.254.17|:80 ...
...

See the resolved IP, there are HTTP responses.




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.