Get a list of used addresses on your network

This comes up from time to time for me. Either myself or someone else needs to see what address are either in use or not in use (at least as far as ping is concerned). So here are a few oneliners to hopefully make your day brighter.

Assuming your network is 192.168.1.0/24 (thats 192.168.1.0-255 255.255.255.0).

Use nmap to ping scan your network


nmap -v -sP 192.168.1.0/24

Use nmap and grep to scan your network and filter for hosts that are “up”


nmap -v -sP 192.168.1.0/24 | grep up

Use nmap and grep to scan your network and filter for ips that are unused or non-responsive


nmap -v -sP 192.168.1.0/24 | grep down

Many times you just want the list of addresses because you are going to do some other processing on them.

Use nmap,  and awk to get only the list of ips that are unresponsive


nmap -v -sP 192.168.1.0/24 | awk '/down/ {print $2}'

Of course you can add some file redirection here if you need to save the output.


nmap -v -sP 192.168.1.0/24 | awk '/down' {print $2}' > iplist.txt

4 Comments

  • Is it unsporting to remind you that many Windows systems come with their firewalls set to drop ICMP echo?

  • It’s not unsporting in the least :). Frankly I use Windows so little that I have not a clue what its default settings are. I’ve always been able to ping windows machines by default iirc. Can you point out the versions that have ICMP echo disabled by default?

  • bouncingsoul Mac OS X Safari 4.0.2 wrote:

    Versions > Windows XP SP 2 that have the firewall enabled drop pings by default.

  • Why? That’s the goofiest thing I’ve heard about MS…well, today, I guess.

    I suppose that’s supposed to be a “security” feature? Kind of like turning off the lights and laying on the floor when trick-or-treaters start ringing the bell?

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha