Logging MAC of all machines on my network











up vote
0
down vote

favorite












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?










share|improve this question


















  • 3




    Use arpwatch.
    – Ipor Sircer
    Nov 29 at 14:24










  • arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
    – Jonas Stumph Stevnsvig
    Nov 30 at 8:38















up vote
0
down vote

favorite












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?










share|improve this question


















  • 3




    Use arpwatch.
    – Ipor Sircer
    Nov 29 at 14:24










  • arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
    – Jonas Stumph Stevnsvig
    Nov 30 at 8:38













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?










share|improve this question













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?







networking cron mac-address network-discovery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 29 at 14:22









Jonas Stumph Stevnsvig

1507




1507








  • 3




    Use arpwatch.
    – Ipor Sircer
    Nov 29 at 14:24










  • arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
    – Jonas Stumph Stevnsvig
    Nov 30 at 8:38














  • 3




    Use arpwatch.
    – Ipor Sircer
    Nov 29 at 14:24










  • arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
    – Jonas Stumph Stevnsvig
    Nov 30 at 8:38








3




3




Use arpwatch.
– Ipor Sircer
Nov 29 at 14:24




Use arpwatch.
– Ipor Sircer
Nov 29 at 14:24












arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
– Jonas Stumph Stevnsvig
Nov 30 at 8:38




arpwatch looks like the proper solution. @IporSircer will you post an answer, so I can accept it?
– Jonas Stumph Stevnsvig
Nov 30 at 8:38










2 Answers
2






active

oldest

votes

















up vote
1
down vote













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






share|improve this answer





















  • ARP table entries do time out.
    – Ron Maupin
    Nov 29 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.)
    – grawity
    Nov 30 at 5:34




















up vote
-3
down vote













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






share|improve this answer





















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











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379432%2flogging-mac-of-all-machines-on-my-network%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













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






share|improve this answer





















  • ARP table entries do time out.
    – Ron Maupin
    Nov 29 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.)
    – grawity
    Nov 30 at 5:34

















up vote
1
down vote













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






share|improve this answer





















  • ARP table entries do time out.
    – Ron Maupin
    Nov 29 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.)
    – grawity
    Nov 30 at 5:34















up vote
1
down vote










up vote
1
down vote









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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 29 at 15:22









James Deal

111




111












  • ARP table entries do time out.
    – Ron Maupin
    Nov 29 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.)
    – grawity
    Nov 30 at 5:34




















  • ARP table entries do time out.
    – Ron Maupin
    Nov 29 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.)
    – grawity
    Nov 30 at 5:34


















ARP table entries do time out.
– Ron Maupin
Nov 29 at 15:28




ARP table entries do time out.
– Ron Maupin
Nov 29 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.)
– grawity
Nov 30 at 5:34






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.)
– grawity
Nov 30 at 5:34














up vote
-3
down vote













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






share|improve this answer





















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















up vote
-3
down vote













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






share|improve this answer





















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













up vote
-3
down vote










up vote
-3
down vote









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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 30 at 12:24









Mick

151




151












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


















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
















I am not just after the list. My code is running nmap, through an api/wrapper.
– Jonas Stumph Stevnsvig
Nov 30 at 12:38




I am not just after the list. My code is running nmap, through an api/wrapper.
– Jonas Stumph Stevnsvig
Nov 30 at 12:38


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379432%2flogging-mac-of-all-machines-on-my-network%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido