Nmap Example: How to Scan Networks and Hosts

nmap example

Nmap (Network Mapper) is a free and open-source tool used to discover hosts and services on a network. It is a powerful tool that can provide information about network topology, operating systems, open ports, and other valuable information that can be used to secure a network. In this article, we will discuss the basics of Nmap and provide some examples of how it can be used.

Nmap Basics

Nmap can be used to scan a single host or a range of hosts on a network. The simplest Nmap command is:

nmap [target]

Where [target] is the IP address or hostname of the target host. This command will perform a basic scan of the target host, displaying open ports and the services running on those ports.

Scanning a Single Host

To scan a single host, simply enter the host’s IP address or hostname as the target:

nmap 192.168.1.1

This command will scan the host with the IP address of 192.168.1.1 and return a list of open ports and services.

Scanning a Range of Hosts

To scan a range of hosts, use the -sL option to list the hosts and the -n option to disable DNS resolution:

nmap -sL -n 192.168.1.1-10

This command will list all the hosts in the range of 192.168.1.1 to 192.168.1.10 without attempting to resolve their hostnames.

Scanning a Network

To scan an entire network, use the -sP option to perform a ping scan:

nmap -sP 192.168.1.0/24

This command will scan the entire 192.168.1.0/24 network, displaying a list of hosts that respond to ping.

Scanning for Open Ports

To scan for open ports on a target host, use the -p option followed by the port number or range of port numbers:

nmap -p 80 192.168.1.1

This command will scan port 80 on the host with the IP address of 192.168.1.1.

nmap -p 1-1000 192.168.1.1

This command will scan ports 1 through 1000 on the host with the IP address of 192.168.1.1.

Scanning for Services

To scan for specific services on a target host, use the -sV option:

nmap -sV 192.168.1.1

This command will scan the host with the IP address of 192.168.1.1 and attempt to identify the services running on open ports.

Scanning with OS Detection

To scan a target host and attempt to identify its operating system, use the -O option:

nmap -O 192.168.1.1

This command will scan the host with the IP address of 192.168.1.1 and attempt to identify its operating system.

Conclusion

In this article, we have discussed the basics of Nmap and provided some examples of how it can be used to scan networks and hosts. Nmap is a powerful tool that can provide valuable information about a network’s topology, operating systems, and open ports. By understanding how to use Nmap, you can better secure your network and identify potential vulnerabilities.