How to use the netcat command in Linux to determine whether a port is open or not
This article mainly introduces how to use the netcat command in Linux to determine whether a port is open or not, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.
How do I use the nc (netcat) command to see if a port is open on a remote Linux system?
Nc is netcat. Netcat is a simple Unix tool that uses TCP or UDP protocols to read and write data between network connections.
It is designed as a reliable back-end tool that can be used directly or simply called by other programs or scripts.
At the same time, it is also a feature-rich network debugging and exploration tool, because it can create almost all types of connections you need, and it also has several built-in interesting features.
Netcat has three kinds of functional modes, which are connection mode, monitoring mode and tunnel mode.
The general syntax of the nc (netcat) command:
$nc [- options] [HostName or IP] [PortNumber]
In the following example, we will check whether port 22 is open on a remote Linux system.
If the port is open, you will get output similar to the following.
# nc-zvw3 192.168.1.8 22Connection to 192.168.1.8 22 port [tcp/ssh] succeeded!
Detailed description of the command:
Nc: that is, the body of the executed command
Z: zero Imax O mode (used for scanning)
V: output explicitly
W3: set the timeout to 3 seconds
192.168.1.8: IP address of the target system
22: the port that needs to be verified.
When you detect that the port is not open, you will get the following output:
# nc-zvw3 192.168.1.95 22nc: connect to 192.168.1.95 port 22 (tcp) failed: Connection refused Thank you for reading this article carefully. I hope the article "how to use the netcat command in Linux to determine whether a port is open or not" shared by the editor will be helpful to you. At the same time, I hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!