0

I would like to know what machines connect to my home network. My thought was to have a MySQL database with an entry for each machine, with the timestamp of when I saw it last, and a tally of how many times I have seen it. That is straightforward. My queston is how do I scan for the MACs? I have considered something like this running every 30 minutes:

    #! /usr/bin/python
    
    import nmap
    
    nm = nmap.PortScanner()
    
    nm.scan(hosts='10.10.10.0/24', arguments='-n -sP -PE)
    hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
    for host, status, mac in hosts_list:
         save(host,status,mac)

... but in order to get the MAC, I need to run this as root.

  • Is there a better way of doing this? (I have considered also if I could get the DHCP records from the router, but that would not find any fixed-ip devices)
  • Could I use another tool?
  • Is there any security measure i can take running a script in cron as root?
2
  • 3
    Use arpwatch. Nov 29, 2018 at 14:24
  • arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
    – JoSSte
    Nov 30, 2018 at 8:38

2 Answers 2

1

From a Windows command line: arp -a will give you the IP and MAC address of every system currently on your network.

2
  • ARP table entries do time out.
    – Ron Maupin
    Nov 29, 2018 at 15:28
  • Which is why you check them often, and check them on the router (not some random PC). It's still more reliable than ping scans. (Although it would be most reliable to directly log the ARP messages themselves.) Nov 30, 2018 at 5:34
-3

Please try to check the following threads, https://askubuntu.com/questions/406792/list-all-mac-addresses-and-their-associated-ip-addresses-in-my-local-network-la https://www.itprotoday.com/cloud-computing/how-can-i-get-list-mac-ip-addresses-network

1
  • I am not just after the list. My code is running nmap, through an api/wrapper.
    – JoSSte
    Nov 30, 2018 at 12:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .