Nmap is one of the most used tools for port scanning. We are using Nmap too. Nmap has a wide variety of parameters and a lot of scripts to work on port scans. Before going into the details of Nmap, let's simply explain what are the TCP protocol, IP addresses, and ports.
TCP (Transmission Control Protocol) is a protocol that define rules to communicate with other system in a network. It is the most used protocol on the Internet. Most other protocols (HTTP, FTP, SSH, etc) use TCP. It defines some rules. The software on both the server and the client side follow these rules and communicate with each other.
Although websites and emails operate over domain names, the addresses that computers can understand are IP's. IP addresses identify servers running on the network (internet). For example, securityforeveryone.com has an IP address (it has a format like 22.214.171.124). This IP address is unique and given to the server in an another country. Whenever you want to access this IP address, the huge infrastructure of the internet directs you to our server and you take the necessary actions. Port are the numbers that define services (softwares) on the server. A port number can be any value between 1 and 65535. There are known ports for known services. Even if you do not enter port information, HTTP requests use port 80 and HTTPS requests use port 443 of the remote server.
We understood the general structure, TCP,IP and Ports. Now let's look at how we can detect remote ports.
There are lots of ports, are we going to scan them all? Yes why not? We do this, but not with this tool. You can use the full port scanning tool to scan them all. This tool scans only the top 10 most used ports. Top 10 most used tcp ports are defined in the nmap page. To summarize we scan these ports:
We were going to write about Nmap's port scanning techniques, but we stopped. Here we say something for everyone, not for experts. So the only thing you need to know is we use Full TCP scan to find open tcp ports which gives the most reliable results for port scanning.
To minimize risks, there are a few things should do.