Using nmap to Scan for Open Ports

Using nmap to Scan for Open Ports

nmap (Network Mapper) is the standard tool for discovering open ports and services on a server or network.

Install nmap

apt install nmap -y    # Ubuntu/Debian
dnf install nmap -y    # CentOS/RHEL

Basic Port Scan

nmap YOUR_SERVER_IP

Scans the 1,000 most common ports and shows which are open.

Scan All 65,535 Ports

nmap -p- YOUR_SERVER_IP

Scan Specific Ports

nmap -p 22,80,443,3306 YOUR_SERVER_IP

Detect Service Versions

nmap -sV YOUR_SERVER_IP

Shows the software and version running on each open port (e.g., nginx 1.24.0).

OS Detection

nmap -O YOUR_SERVER_IP

UDP Scan

nmap -sU -p 53,67,123,161 YOUR_SERVER_IP

Output Formats

nmap -oN output.txt YOUR_SERVER_IP     # Normal text
nmap -oX output.xml YOUR_SERVER_IP     # XML format

Verify Your Own Firewall Rules

Run nmap against your server from a different machine (or use an online nmap tool) to verify your firewall is blocking the ports you expect:

nmap -p 22,80,443,3306,5432 YOUR_SERVER_IP

Ports with status filtered are being blocked by the firewall. Ports with status closed are not blocked but nothing is listening.

  • 0 用戶發現這個有用
這篇文章有幫助嗎?

相關文章

Understanding Your Server's Network Configuration

Understanding Your Server's Network Configuration Knowing how to read and manage your server's...

Setting Up Reverse DNS (rDNS/PTR Record)

Setting Up Reverse DNS (rDNS / PTR Record) A reverse DNS (PTR) record maps your IP address back...

How to Configure a Static IP Address on Linux

Configuring a Static IP Address on Linux Dedicated servers typically have a static IP configured...

Setting Up Nginx as a Reverse Proxy

Setting Up Nginx as a Reverse Proxy A reverse proxy forwards incoming requests to a backend...

How to Configure DNS Records for Your Domain

Configuring DNS Records for Your Domain DNS records tell the internet how to reach your domain....