Not everything with an IP address is a computer - I found none of these suggestions returned all active IP addresses - in fact most returned very few. My home network has a combination of wired and wireless devices and two routers, mobile phones, TV, PVR, Apple AirPort and probably a few things I have forgotten. I used the following to scan all addresses on the 192.168.1.xxx subnet:
for /L %i in (0,1,255) do ping -n 1 -w 250 192.168.1.%i>>ipaddress.txt
The resulting file ipaddress.txt contains the ping results for all addresses and I looked for those with "Received = 1" - currently 16 addresses returned a result - I only have 4 computers in the house - and they were not all on.
Not everything with an IP address is a computer - I found none of these suggestions returned all active IP addresses - in fact most returned very few. My home network has a combination of wired and wireless devices and two routers, mobile phones, TV, PVR, Apple AirPort and probably a few things I have forgotten. I used the following to scan all addresses on the 192.168.1.xxx subnet:
for /L %i in (0,1,255) do ping -n 1 -w 250 192.168.1.%i>>ipaddress.txt
The resulting file ipaddress.txt contains the ping results for all addresses and I looked for those with "Received = 1" - currently 16 addresses returned a result - I only have 4 computers in the house - and they were not all on.
You could do the arp -a command to show all ARP entries in the table about computers on your network.
Source
ip - List ALL devices on local network? - Stack Overflow
List all IP devices in the network - cmd/powershell - Networking - Spiceworks Community
How to find network details for another device on my local network
network programming - discover the devices connected to the computer via command line? - Stack Overflow
How to display network devices in Windows Explorer?
Which is a network device tool?
The term “network device” refers to the equipment that runs a network rather than the computers that store programs and files. These are systems such as switches, routers, and hardware firewalls. A new network administrator won’t necessarily know what devices are on a network or how they fit together, so a network device discovery tool can help identify all devices, log them in an inventory, and create a topology map.
What is a network discovery scan?
There are two types of network discovery tools. The simplest of these is an IP scanner, which intends to list all of the IP addresses that are in use on the network. A network device discovery tool will give detailed information on the device associated with each IP address that it finds is in use.
Videos
arp -a will show you only MAC addresses that are stored in local ARP cache and your computer was connected to. When I'm trying to see every device in my local network I have to scan it. For example if you have 192.168.1.0/24 network you can do:
$ for i in `seq 1 254`; do
ping -c 1 -q 192.168.1.$i &
done
You will try to ping every computer in your network. Of course not every computer will answer for ping. This is why you can't rely on ping. Now you need to check ARP cache.
$ arp -a | grep 192.168.1. | grep ether
This command will show you ARP cache filtered only with computers that are in this network and that answered on ARP requests (in 99% cases it will be full list of devices in your network - just remember that ARP entry is not removed immediately when the device disconnects).
There are several ways to generate list of devices on a network however it depends on what resources you have available to use.
- ping the possible list of devices
- access the list of devices from your router
- use a third party wire sniffing tool
Note that there are a number of reasons why a device may be on a network yet not "discoverable". For a Windows PC, Network discovery may be turned off. A firewall may be filtering out ICMP Echo requests or replying to ICMP Echo requests may be turned off.
Ping the network for devices - Windows OS
To generate a list with a Windows CMD .bat file to ping devices on the network, do the following.
Create a .bat file with a loop that uses the ping command to send a ping to each of the possible usable addresses on your network. I use the -a and -n 1 options on the ping command to send a single ping, -n 1, with a request to give me the hostname. After pinging the network you can then use the arp command to get a concise list using arp -a >con which will redirect the output to the console even when the .bat file is redirected to a file.
The following commands in a Windows .bat file seems to do the trick.
for /L %%i in (1,1,254) do (
ping -a -n 1 192.168.0.%%i
)
arp -a >con
Next run the .bat file sending the output to a text file:
listdev.bat > listdev.txt
This will generate a text file with the results of the ping commands. It will look something like the following:
C:\Users\rcham>(ping -a -n 1 192.168.0.3 )
Pinging DESKTOP-GFSP7AC.xxxxxxxx.net [192.168.0.3] with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.0.3:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
C:\Users\rcham>(ping -a -n 1 192.168.0.4 )
Pinging rick-MS-7B98.xxxxxxxx.net [192.168.0.4] with 32 bytes of data:
Reply from 192.168.0.4: bytes=32 time=5ms TTL=64
Ping statistics for 192.168.0.4:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 5ms, Maximum = 5ms, Average = 5ms
C:\Users\rcham>(ping -a -n 1 192.168.0.5 )
Pinging 192.168.0.5 with 32 bytes of data:
Reply from 192.168.0.148: Destination host unreachable.
Ping statistics for 192.168.0.5:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
C:\Users\rcham>(ping -a -n 1 192.168.0.6 )
Pinging 192.168.0.6 with 32 bytes of data:
Reply from 192.168.0.148: Destination host unreachable.
Ping statistics for 192.168.0.6:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
C:\Users\rcham>(ping -a -n 1 192.168.0.7 )
Pinging 192.168.0.7 with 32 bytes of data:
Reply from 192.168.0.148: Destination host unreachable.
Ping statistics for 192.168.0.7:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
C:\Users\rcham>(ping -a -n 1 192.168.0.8 )
Pinging SurfacePro-2.xxxxxxxx.net [192.168.0.8] with 32 bytes of data:
Reply from 192.168.0.148: Destination host unreachable.
Ping statistics for 192.168.0.8:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
C:\Users\rcham>(ping -a -n 1 192.168.0.9 )
Pinging starfive.xxxxxxxx.net [192.168.0.9] with 32 bytes of data:
Reply from 192.168.0.148: Destination host unreachable.
Ping statistics for 192.168.0.9:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Notice in the list above that there are differences in responses to the ping command.
- response received
- request timed out
- reply of Destination host unreachable.
The first means that there was an operational device connected to the network with that IP address and the device was configured to reply to the ICMP Echo request of the ping command.
The second means that there may be a device connected to the network with that IP address however the device may be configured to ignore ICMP Echo requests or it is powered off and can't reply. There may be other possible causes but these two are the most common in a small network.
The third means the router didn't have a way to send the ICMP Echo request to the designated IP address so the request wasn't sent.
For the difference between the two last responses with more details see the post ping response "Request timed out." vs "Destination Host unreachable"
Forewarning: I am not the greatest when it comes to networking
I know enough that if I wanted to find my computer's IP address and subnet I can go into Command Prompt and use ipconfig /all
I am currently looking to get the subnet mask of another device on my network who's local IP address I know.
I am looking to make a WD My Book Live a static IP, but need to input a subnet mask, but I'm unsure of what it's current one is. I don't know enough about networking to really understand what it is either.
Sorry if I did not explain this properly.
For the first scenario, look at nmap. You can scan entire subnets in one command. For example: nmap -sP 192.168.0.1/24
For the second, the router IP should show up as the gateway IP for your machine. In windows, that appears in the connection status dialog.
You can ping to the broadcast address and see arp table. Here is a example of doing it on Linux:
ping -b 192.168.1.255
arp -n
NB: The OS of the device have to echo back to ICMP echo request. Some OS don't reply to ICMP with broadcast IP adress. In which case you can ping to every possible ip address in the network. Recently windows boxes don't reply to ICMP echo with unicast IP address by default, so this won't help.