2

I have a script on a Ubuntu 10.04 box happily producing LAN info using nmap 5.00. I want to replace the box with an RPi running Raspbian, however nmap is version 6.00, runs more slowly, doesn't find all the devices, and doesn't return MAC addresses, which are what I need............

nmap -sP 192.168.1.*

RPi:
Starting Nmap 6.00 ( http://nmap.org ) at 2013-09-08 18:40 ICT
Nmap scan report for login.router (192.168.1.1)
Host is up (0.0063s latency).
Nmap scan report for 192.168.1.2
Host is up (0.0057s latency).
Nmap scan report for 192.168.1.5
Host is up (0.0039s latency).
Nmap scan report for 192.168.1.10
Host is up (0.0023s latency).
Nmap scan report for 192.168.1.11
Host is up (0.014s latency).
Nmap scan report for 192.168.1.12
Host is up (0.014s latency).
Nmap scan report for 192.168.1.101
Host is up (0.0064s latency).
Nmap done: 256 IP addresses (7 hosts up) scanned in 11.53 seconds

Ubuntu:
Starting Nmap 5.00 ( http://nmap.org ) at 2013-09-08 18:41 ICT
Host 192.168.1.1 is up (0.00042s latency).
MAC Address: 00:30:0A:CF:8F:D3 (Aztech Systems)
Host 192.168.1.2 is up (0.00075s latency).
MAC Address: 00:24:36:9E:F1:31 (Apple)
Host 192.168.1.3 is up (0.00014s latency).
MAC Address: EC:88:8F:BB:57:57 (Unknown)
Host 192.168.1.4 is up (0.00059s latency).
MAC Address: 80:C1:6E:46:6E:CC (Unknown)
Host 192.168.1.5 is up (0.00063s latency).
MAC Address: B8:27:EB:A2:23:7D (Unknown)
Host 192.168.1.6 is up (0.00074s latency).
MAC Address: B8:97:5A:48:B9:7D (Unknown)
Host 192.168.1.7 is up (0.0014s latency).
MAC Address: 00:25:22:58:B7:3F (ASRock Incorporation)
Host 192.168.1.8 is up (0.023s latency).
MAC Address: 00:1D:0F:CE:AD:9C (Tp-link Technologies Co.)
Host 192.168.1.10 is up (0.0019s latency).
MAC Address: 00:24:8C:B7:1F:3A (Asustek Computer)
Host 192.168.1.11 is up (0.00061s latency).
MAC Address: B8:27:EB:26:10:BC (Unknown)
Host 192.168.1.12 is up (0.00013s latency).
MAC Address: 90:2B:34:96:51:E7 (Unknown)
Host 192.168.1.101 is up.
Nmap done: 256 IP addresses (12 hosts up) scanned in 4.49 seconds

There isn't an older version available for the RPi as far as I can see.
Any ideas how to get the same reliable data?

sudo nmap -PY -p 445 -n 192.168.1.* yields what I need, but it leaves me with needing to run nmap from the php script as root - another hole to look into.....

  • I am not an expert on nmap, and have not tried it on Rasbpian, but MAC is not generally available. Have you tried "sudo nmap ..." This works on OSX. – Milliways Sep 9 '13 at 4:47
  • Have you considered compiling nmap 6 from source on the Pi? – fouric Dec 8 '13 at 23:20
  • Using nmap 6.46, running nmap -sP 192.168.1.* does not display MAC's, while sudo nmap -sP 192.168.1.* DOES display them. Guess you have to have root powers to see MAC addresses in the output. Easy enough. – lornix Jul 7 '14 at 18:56
1

You can use /usr/sbin/arp to resolve IP addresses (or hostnames) to MAC addresses. You need a little bit more scripting (parse the output of nmap or use grep and cut), but it should work on almost any Linux machine.

1

As suggested by Arne you can use the ARP table to resolve the ip address to MAC addresses. If you don't want to execute that as root (or sudo for that matter), use iproute2 utility. Not sure iproute2 is installed by default on your RPI though. If not, install it. Very useful utility.

  1. Populate the ARP table by running your nmap -sP 192.168.0.* command
  2. immediately thereafter run: ip neigh | awk '!/FAILED/{print $1,$5}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.