"If you wish to know the number of systems running on a network along with the mac and IP addresses of each computer, you need to install the 'fping' package on your Linux system."
#apt-get install fping
After the successful installation of 'fping'. Run the command below from the terminal to know how many systems are alive on your network
#fping -s -g 192.168.0.254 -r 1
Here.....
's' stands for 'status'
'g' for 'range'
'r' for 'retry'
To know the IP address only of the machines currently running on the network, type the following command:
#fping -g 192.168.0.1 192.168.0.254 -r 1 | grep -v unreachable | awk '{print $1}'
if you need the IP address along with these machines ' mac addresses, run the following command:
#fping -g 192.168.0.1 192.168.0.254 -r 1 | grep -v unreachable | awk '{print $1}' | while read output; do arp $output | grep -v Address | awk '{print $1 “ “ $3}' >> ip-mac.txt; done
The above command will make a file called 'ip-mac.txt' in which all the running mackines ' IP addresses will get stored along with the associated systems ' mac addresses.
However, on some systems, you might need to set the environment variable to run the above command successfully.
Given below are the steps to set the environment variable:
export PATH=/sbin/:$PATH
export PATH=/usr/sbin/:$PATH
export PATH=/bin/:$PATH
export PATH=/usr/bin/:$PATH
If the commands do not run due to environment variable issues, you can also try running them by giving the full path for the command.
To run the command, using the full path, first check the complete path of 'fping' and 'arp' as follows:
#whereis fping
#whereis arp
….and then add 'full path' in the command.
For example: /usr/bin/fping, /usr/sbin/arp
Hope you enjoyed getting the information of the systems in the network.
To do this on a Red Hat-based system, run the following command as the root user
#yum -y install fping
If you work on a Debian-based system, type the following command#apt-get install fping
After the successful installation of 'fping'. Run the command below from the terminal to know how many systems are alive on your network
#fping -s -g 192.168.0.254 -r 1
Here.....
's' stands for 'status'
'g' for 'range'
'r' for 'retry'
To know the IP address only of the machines currently running on the network, type the following command:
#fping -g 192.168.0.1 192.168.0.254 -r 1 | grep -v unreachable | awk '{print $1}'
if you need the IP address along with these machines ' mac addresses, run the following command:
#fping -g 192.168.0.1 192.168.0.254 -r 1 | grep -v unreachable | awk '{print $1}' | while read output; do arp $output | grep -v Address | awk '{print $1 “ “ $3}' >> ip-mac.txt; done
The above command will make a file called 'ip-mac.txt' in which all the running mackines ' IP addresses will get stored along with the associated systems ' mac addresses.
However, on some systems, you might need to set the environment variable to run the above command successfully.
Given below are the steps to set the environment variable:
export PATH=/sbin/:$PATH
export PATH=/usr/sbin/:$PATH
export PATH=/bin/:$PATH
export PATH=/usr/bin/:$PATH
If the commands do not run due to environment variable issues, you can also try running them by giving the full path for the command.
To run the command, using the full path, first check the complete path of 'fping' and 'arp' as follows:
#whereis fping
#whereis arp
….and then add 'full path' in the command.
For example: /usr/bin/fping, /usr/sbin/arp
Hope you enjoyed getting the information of the systems in the network.