Linux and Unix Port Scanning With netcat [nc] Command

Linux and Unix Port Scanning With netcat [nc] Command

The nc (netcat) command is a utility for reading and writing data across networks. It can be used for a variety of purposes, including port scanning.

To use nc for port scanning, you can specify the hostname or IP address of the target system and a range of port numbers to scan. For example, to scan for open ports on a system with IP address 192.168.1.100, you can use the following command:

ref‮ot re‬:lautturi.com
nc -v -n -z 192.168.1.100 1-1024

This command will attempt to connect to each port in the range 1-1024 on the target system and report whether the connection was successful. The -v flag enables verbose output, which will show the progress of the scan, and the -n flag disables DNS lookups to improve performance. The -z flag tells nc to perform a "zero-I/O" scan, which means that it will not actually send any data to the target system, but will simply try to establish a connection and then close it.

You can also specify a specific port number instead of a range if you only want to scan for a single port. For example:

nc -v -n 192.168.1.100 80

This command will attempt to connect to port 80 on the target system. If the connection is successful, it means that the port is open. If the connection is refused or times out, it means that the port is closed or blocked.

Keep in mind that port scanning is generally considered a security risk and may be considered unauthorized or illegal in certain contexts. It is important to respect the privacy and security of other systems and only perform port scans with explicit permission.

Created Time:2017-10-29 22:09:00  Author:lautturi