The first of these was with my Raspberry Pi. I tend to run this as a headless server and normally SSH into it. This is impossible until I have established its IP address.
The second, and more recent, is with a new piece of hardware which the company I work for has developed. This runs embedded Linux and requires us to find its IP address in order to operate it.
For my Raspberry Pi my usual method of finding the IP address was to log into my router and check which devices were connected. As I regularly reformat my Raspberry Pi this is something I need to do often. I have always felt this was extremely cumbersome, and I am forever scrabbling around trying to find the log in details for my router.
When my colleagues needed to find our new device on the network at work, I explained my method of logging into the router and checking for the IP addresses. The company router however was not as friendly as my home one, and promptly spat out a list of 20 IP addresses. My colleagues checked these manually to find the new device. Needless to say this took time and is not a long term solution.
As an experiment I wrote a python script to ping all the IP addresses, and log the one we required. My fears were correct, that pinging 256 IP address was extremely slow!
Surely there must be a better way to do this? Initial Google searches showed other people stating they connected a TV and keyboard to the Raspberry Pi. They could then determine the IP address by typing ifconfig into the command line. What a pain!
Further searching revealed an excellent tool called nMap.
Even more appealing is the fact it works with Linux, Mac and Windows. I need to use it on all three.
I installed it on a Linux machine and ran the following from a command line:
sudo nmap -sn 192.168.1.0/24
Within seconds a list of all connected devices and their IP addresses appeared. Problem solved!
So how do you install nMap?
On a Linux system such as Raspbian it's simple. Just type the following into the command line:
sudo apt-get install nmap
Windows and Mac users need to run an installer which has the option of running a GUI (Graphical User Interface) version called Zenmap.
The installer can be found on the nmap website here:
I would recommend using the command line where possible. It really does save time and effort not having to run a GUI. Particularly if you are remotely logged in via SSH.
For Linux the command would be:
sudo nmap -sn 192.168.1.0/24
sudo is required to give you root permissions.
For Mac and PC just type:
nmap -sn 192.168.1.0/24
If you prefer a GUI version rather than using the command line then you are in luck! During installation onto the Apple Mac or PC you have the option to install Zenmap.
To use this load Zenmap and follow the three easy commands below.
- In the Target box type: 192.168.1.0/24
- Select Profile: Ping scan
- Click on: Scan
I hope you all find this as useful as I did!