nmap is a very useful tool to check the open ports. Yeah, bad guys could use it too but you want to make sure the host you have exposed to the Internet has the minimal number of ports open. When I scan my own host that hosts this blog site like
nmap hayato-iriumi.net, I get the following output.
Starting Nmap 7.80 ( https://nmap.org ) at 2021-09-23 18:27 PDT Nmap scan report for hayato-iriumi.net (18.104.22.168) Host is up (0.097s latency). Not shown: 996 filtered ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp open https 8080/tcp open http-proxy
I have the 4 ports open intentionally for my own management of my site. This makes me think what I should actually do down the road. I should close 22 and use a bastion to SSH into the host for management.
8080 is open for another management reason. Obviously, 80 is open for HTTP connection which redirects traffic to 443 (SSL, HTTPS). If you do
nmap google.com, you can see port 80 and 443 are open to public as well.
Starting Nmap 7.80 ( https://nmap.org ) at 2021-09-23 18:28 PDT Nmap scan report for google.com (22.214.171.124) Host is up (0.026s latency). Other addresses for google.com (not scanned): 2607:f8b0:400a:805::200e rDNS record for 126.96.36.199: sea30s08-in-f14.1e100.net Not shown: 998 filtered ports PORT STATE SERVICE 80/tcp open http 443/tcp open https
Here is the first paragraph of nmap man page. It tells you what it’s supposed to do.
Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.
man page for nmap is pretty big so there must be a lot we can do with this tool.