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.