today-i-learnt

All mac addresses in LAN

Category: sysadmin Generated on 2016-03-08

A quick how to list all MAC address present in a LAN segment

arp-scan

$ sudo arp-scan --interface=eth0 --retry=3 --timeout=200 --localnet --random 

From man:

arp-scan sends ARP packets to hosts on the local network and displays any responses that are received.

Options explained:

See man arp-scan for further details.

arping

Ping destination on device interface by ARP packets, using source address source.

Useful to check for a specific host.

$ sudo arping -f -I eth0 -c 3 192.168.1.1

nmap

$ sudo nmap -sP -PE -PA21,22,23,80,3389 192.168.1.0/24

To process nmap output:

Nmap scan report for ([0-9]+.[0-9]+.[0-9]+.[0-9]+)\nHost is up \(.* latency\).*\nMAC Address: (.*) \((.*)\)

\1 is ip \2 is mac \3 is vendor