Skip to content

Instantly share code, notes, and snippets.

@pierdom
Last active September 7, 2017 07:55
Show Gist options
  • Save pierdom/9598d3d60fbf470527824ad37c82f510 to your computer and use it in GitHub Desktop.
Save pierdom/9598d3d60fbf470527824ad37c82f510 to your computer and use it in GitHub Desktop.
[Discover IP and MAC addresses in local network] using standard ping or arp-scan #linux #macosx #networking #sysadmin

Note: I assume the addressing space of the local network is 192.168.1.1/255.255.255.0.

Look for IP addresses (no admin rights required)

for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done

Look for MAC and IP addresses (with admin rights)

Install arp-scan. On Mac with homebrew:

brew install arp-scan

on Ubuntu/Debian with apt-get:

sudo apt-get install arp-scan

Scan local network:

sudo arp-scan -l

Scan local network specifying network interface (it might be required if arp-scan is not able to decide which one to use):

sudo arp-scan --interface eth0 -l

Specify a range:

sudo arp-scan 192.168.1.1-192.168.1.50
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment