This kind of project has been done with Bluetooth before but the 30 foot range and extra battery consumption make me want to just ping the router instead of people's phones. I know that routers keep track of unique MAC address's for each device. I was hoping to register each phone's address and have the PI Periodically check the router to update a dynamic web page to display who is home.

I want to know if there is a reasonable way to pull this info with the PI.

  • what about wifi (ping the phones hostnames instead)?
    – user236012
    Feb 23, 2016 at 22:49
  • 2
    You could also assign static IP addresses from the router, then use nmap and the IP addresses to identify devices.
    – ArtOfCode
    Feb 24, 2016 at 0:18
  • I have done something similar in C# on Windows here: stackoverflow.com/questions/2567107/… - I'd be happy to send you the most recent version code if you'd like. I don't know how useful C# is on a Raspberry Pi, but it should point you in the right direction. It reliably detects that I'm home before I even get in from the garage. Feb 24, 2016 at 3:59
  • I capture this + a whole lot more information by putting a bash script on the router that posts the results into a webserver every minute. With this sysem I monitor and manage internet uptime, connected clients, WAN IP's, fiber attenuation and power budget, VOIP services, wifi passwords etc. Mileage differs by your the CPU power of your router.
    – EDP
    Feb 24, 2016 at 5:01
  • 1
    Screen scraping on the router? You could also upgrade to a Linuxbased router (openwrt) and simply log in and look in the arp cache. Feb 24, 2016 at 9:39

5 Answers 5


It is possible. I suggest you provide your script with login credentials and read the page that display the info. Then you could parse it's content and fill an array with the data you want. Since these pages sometimes contain more information like dates and time you could build a really nice log.

Here is a quick example on how I would proceed;

On your router's page you could find something like the following;

<div id="flex">
 <div id="dm-name">
  name : Your_device_name
 <div id="dm-ip">
  IP : 192.168.x.xxx
 <div id="dm-mac">

So we know wright that every device will be listed like that. And that all MAC adresse will have the same length.

The script could be something like that;

var string_to_parse = "file read from router.html";
cursor = 0;  // The position of your cursor;
i =0;
    while(cursor > 0){

    begin_at = string_to_parse.indeOf('MAC:');
    end_at = length_of_Mac; // this is standard for al mac

    mac[i] = string_to_parse.substring(begin_at, begin_at + end_at);
    cursor = begin_at + end_at;

This code will need tweaking but the idea is there. Its a loop that will run all the file to find all Mac adresse. until it reach the end of the file.

  • This is what I would do. It has the added bonus of detecting if your router is dead.
    – slebetman
    Feb 24, 2016 at 2:44
  • 1
    +1 Website scraping is an interesting choice. I'm slightly annoyed I didn't think of it myself.
    – Jacobm001
    Feb 24, 2016 at 3:50
  • @MadeInDreams The router page that you refer is the router DHCP lease page? Or is there a router active connection page? Feb 24, 2016 at 9:00
  • Depend on your router but most of them have a page that list all the device connected. This example is from my network main page Feb 24, 2016 at 17:16

In order to track unique mac addresses on your Raspberry Pi, you need a tool (rather service) called arpwatch. I have used arpwatch on BSD extensively and it logs all arp and rarp requests into syslog.

From Syslog you can parse dates and times and mac addresses.

ARP works and table exists only on the physical network (technical word: collision domain). When a packet leaves for another network, the source mac address is replaced by router's mac address.

Running arp command on Raspberry Pi will only list mac + IP addresses of hosts who have transacted (IP communication) with the host on which the command is run (Raspberry Pi). It will not list mac addresses of other hosts on the network.

Another advanced way would be to use nmap on your Raspberry Pi to do a host discovery. You can use nmap -sP to ping all hosts on the network. It will tell you IP addresses of all active hosts on your network. Then you can run arp command to find out mac of who is active.

chetan@Linux:~$ nmap -sP

Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-23 16:08 PST
Nmap scan report for
Host is up (0.0087s latency).
Nmap scan report for
Host is up (0.0024s latency).
Nmap scan report for
Host is up (0.049s latency).
Nmap scan report for
Host is up (0.063s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.68 seconds
  • 1
    I think this is probably a much more robust and flexible method than the web scraping one. On many ISP issued routers the page that is supposed to show connected devices w/ info will not be reliable.
    – goldilocks
    Feb 24, 2016 at 8:26
  • @goldilocks +1, yes, I thought about it after I upvoted the accepted answer. I assume they have a router that has a page for active connections (SPI status or similar). Nice router they have. Feb 24, 2016 at 9:03

I've just been playing around with the command line version of fing. It does a decent job of finding everything on the network and spitting out CSV files containing:

  • IP address
  • Custom Name of the Node (if you have assigned custom names in the .properties file)
  • The state (UP/DOWN)
  • The timestamp of last change
  • The host name (if you have enabled DNS)
  • The Hardware address (if you are discoverying a local network)
  • The Hardware vendor

Per previous answers, some text manipulation would be necessary to get the contents of the CSVs onto a web page, and be careful what you're publishing externally.

I've used the Android version pretty extensively and it does a good job of finding everything on my home network (and kind of fun to play with on public wifi).


The command arp will give you a list of devices connected to the network. You'll need to do some basic string manipulation to get the data you want, but that would certainly be easier than trying to get the information yourself.

Functionality note:

Some routers block this type of functionality by default, and yours may be configured as such. If it doesn't work, dig around it's documentation a little to check how to allow it.


There are some very serious security implications of having a website that displays who's currently home. Please think very carefully about the security in place, and whether it's good enough for the risks involved.

  • Good idea, I guess I withdraw my previous comment.
    – Ghanima
    Feb 23, 2016 at 22:44
  • 1
    There are a couple of interesting looking caveats about using arp for this here. They suggest that devices might not show up if they haven't sent any packets to the arp-running device, and that a ping might be necessary.
    – goobering
    Feb 23, 2016 at 23:49
  • @goobering +1. simply running arp command will not list all the active hosts on the network. Arpwatch will log all arp packets on the network. Feb 23, 2016 at 23:58

It is possible to do, and other people have suggested some good methods. I wrote a python script a few years back to screen scrape this information from a netgear router and threw it up on github. It can be found here. It is crude, and looking at it now I would redo it somewhat differently, but it worked for pretty much the exact same purpose as you are after for a couple of years until I moved.

  • +1 Your script could certainly be improved, but that's a great solution to the problem.
    – Jacobm001
    Feb 24, 2016 at 19:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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