As Ubuntu users, we may want to know if we are the only ones using our network, especially the WLAN, or if there are other unwanted users exploiting our network bandwidth. This capability and knowledge are also helpful when we want to be sure that no hacker is accessing our system by connecting to our network.
Scan your network with Nmap on Ubuntu
This article describes step by step how to use the Nmap tool, which provides you with a list of all devices connected to your network. We have run the commands and procedures described in this article on Ubuntu 22.04 LTS.
Step 1: Open the Ubuntu command line
We will be using the Ubuntu command line, the Terminal, in order to view the devices connected to our network. Open the Terminal either through the system Dash or the Ctrl+Alt+T shortcut.
Step 2: Install the network scanning tool Nmap
When it comes to reliable network scanning, Nmap is a tool that you can totally depend on.
Enter the following command as sudo in the Terminal application in order to install the tool.
The system will ask you for the password for sudo since only an authorized user can install/uninstall and configure software on Ubuntu.
The system will also ask you to confirm the installation with y/n. Please type y and press enter to start the installation process.
Step 3: Determine the IP range/subnet mask of your network
In order to know which devices are connected to your network, you first need to determine the IP range or subnet mask of your network. We will use the ifconfig command to determine this IP. In order to run the ifconfig command, we need to install the net-tools package on our Ubuntu server or desktop. Use the following command to install net-tools if you do not already have it installed on your system:
$ sudo apt install net-tools
The system will prompt you with a y/n option to confirm the installation. Please enter Y and hit enter to begin the installation process.
Once you have the net-tools utility available, run the following command in order to get information about the network(s) your system is connected to:
The highlighted IP in the output shows that our system uses the subnet mask 192.168.100.0 and the range is 255. So our network IP range is from 192.168.100.0 to 192.168.100.255.
Alternative Installation via Ubuntu GUI
Instead of using the ifconfig tool, you can also get the subnet mask from the Ubuntu user interface.
Access the settings utility in System Dash and check the details of your network by clicking on the settings icon next to the WLAN or Ethernet network you are connected to.
In this example, we have checked the settings of a wi-fi network we are currently connected to.
The highlighted ipv4 address or the Default Route address indicates that we are connected to a subnet IP 192.168.100.0
Step 4: Scan the network for the connected device(s) with Nmap
Through the Nmap tool, you can scan the report of all devices connected to a network by providing the subnet mask IP as follows:
$ nmap -sP 192.168.100.0/24
The output shows that three devices are connected to the network: the router itself, the Linux system I use on my laptop, and my phone.
Step 5: Exit the terminal
Use the following command to exit the terminal application after extracting the information you need:
In this article, you learned how an Ubuntu user can install and use the Nmap command. We showed you how to see which devices are connected to your network. This way you can verify that no unauthorized device is connected to your network.