nmap Command: Scan A Single IP Address or Host

How do I use nmap command to scan a single server using a host name or an IP address under Unix like operating systems?

You can use a nmap command to scan a single server using a host name such as server1.cyberciti.biz or an IP address such as 192.168.1.254. The syntax is:
Tutorial details
Difficulty level Easy
Root privileges No
Requirements nmap
Est. reading time N/A

nmap host-name-here

OR

nmap IP-address-here

This example demonstrates port scanning using an IP address:
$ nmap 192.168.1.1
This example demonstrates port scanning using a host name:
$ nmap router
Sample outputs:
Fig.01: nmap command output

Fig.01: nmap command output

Understanding nmap command output

  • Not shown: 998 closed ports – By default nmap will show open ports only in the following format.
    • PORT – Port number with protocol.
    • STATE -The state is either open, filtered, closed, or unfiltered. Open state means that an application on the target machine is listening for connections/packets on that port. Filtered state means that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed.
    • SERVICE The service name. For example, the port # 22 is often used by ssh service such as OpenSSH server or the port # 80 is often used by a web server such as Apache.

To scan multiple IP addresses or hosts names:
$ nmap server1 server2 server2.nixcraft.net.in
$ nmap 192.168.1.1 192.168.1.2

Sample outputs:

Fig.02: nmap scan for multiple hosts

Tip: You can use nmap 192.168.1.1,2 instead of typing nmap 192.168.1.1 192.168.1.2, as both IP addresses are part of the same subnet 192.168.1.0/24.

To speed up nmap execution pass the -T4 option as follows:
$ nmap -T4 192.168.1.1


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum