Checking for hosts and services in MSF

So far, we have covered the basics of msfconsole. Now, let's move on and learn how to manage hosts and services:

  1. To view a list of all hosts that have been added, use the hosts command:

  1. To add a new host, we can use the hosts -a <IP> command, as shown in the following screenshot:

  1. To remove a host, we use the hosts -d <IP> command, as shown in the following screenshot:

Similarly, the services command allows us to view a list of all the services that are available across all the hosts that have been added to Metasploit. Let's take a look:

  1. First, we need to use the services command:

  1. To view the list of services for a single host, we can use the services <IP> command, as shown in the following screenshot:


We cannot add multiple ports at once. Doing that will throw an error Exactly one port required as shown in the preceding screenshot.

Metasploit also allows us to add a custom service manually by using the services -a -p <port number> command, as shown in the following screenshot:

Next, let's look at Nmap scanning with MSF.