How to Use the Nmap Tool to Detect Port Usage for Cloud Server Applications?

20-02-2024 03:17:07

Nmap is a tool designed to verify if applications are listening on ports, enabling the inspection of the status of one or several ports.

Common parameters for Nmap include:

  • -Pn : Treat all hosts as online and skip host discovery.
  • -p : List of ports to scan.
  • --reason : Display the reason a port is in a particular state.

For instance, the command to scan ports 22, 53, 80, and 443 on the cloud server with the IP address 192.0.2.2 is as follows.

$ nmap -Pn -p 22,53,80,443 --reason 192.0.2.2

PORT    STATE    SERVICE REASON
22/tcp  open     ssh     syn-ack
53/tcp  filtered domain  no-response
80/tcp  filtered http    no-response
443/tcp filtered https   no-response

Nmap done: 1 IP address (1 host up) scanned in 12.64 seconds

The output of the above indicates that SSH on port 22 is open, while DNS (port 53), HTTP (port 80), and HTTPS (port 443) are unresponsive. If Nmap's output shows a port is open but a connection cannot be established, then the issue likely does not lie within the application configuration or the operating system's firewall settings, but rather at a higher level, such as restrictions from the cloud computing platform's security groups.