I have several linux devices connected to the same router (of which I am not a administrator). How can I find out the ip addresses of all other devices by executing some commands in one of them?
- related (with links to a lot of duplicate quesions): How can I list all IPs in the connected network, through Terminal preferably?Alexander Malakhov– Alexander Malakhov2016-10-22 09:24:08 +00:00Commented Oct 22, 2016 at 9:24
- If this is a router and not a switch, I'm not sure if you can. A router doesn't pass broadcasts by default, and each device might be on a different subnet, so arp/nmap/fing/ping might be useless.Dani_l– Dani_l2018-12-16 11:19:00 +00:00Commented Dec 16, 2018 at 11:19
2 Answers
I believe you could use nmap to get such information.
The below command lists me all the machines/devices connected in my network. It is a home network and it lists me all the machines in my home.
nmap -sP 192.168.1.0/24 I believe you need to modify the subnet mask and IP range that you are in to suit your requirements.
- 3why 192.168.1.0/24? what means?Tarlo_x– Tarlo_x2015-11-07 13:15:05 +00:00Commented Nov 7, 2015 at 13:15
- 6
nmap -sA 192.168.1.0/24nmap option-sAshows similar descriptive results with better readability, which includes device name, IP, mac, etc as with option-sP. I personally prefer-sAover-sPfor the readability sake.Jay– Jay2016-02-03 10:17:01 +00:00Commented Feb 3, 2016 at 10:17 - 2@Tarlo_x superuser.com/questions/970380/…Alessandro Jacopson– Alessandro Jacopson2018-09-02 09:30:06 +00:00Commented Sep 2, 2018 at 9:30
For a more compact list of connected devices:
nmap -sL 192.168.0.* | grep \(1 Explanation
nmap -sL 192.168.0.* will list all IPs in subnetwork and mark those, that have name:
Nmap scan report for 192.168.0.0 Nmap scan report for Dlink-Router.Dlink (192.168.0.1) Nmap scan report for 192.168.0.2 ... Nmap scan report for android-473e80f183648322.Dlink (192.168.0.53) ... Nmap scan report for 192.168.0.255 As all interesting records contain parenthesis ( and digit 1, we filter for that with | grep \(1 (backslash is needed to escape parenthesis)
Quirk
Beware that if two devices have the same name, nmap will show only the one, that was connected to router last