I have already configured my Raspberry Pi as an access point. I, now, need to see/log the details about the devices which had connected to my Pi.

My use case is to configure a metered connection through my Pi, i.e., each device which connects to my Pi should only be allowed a fixed amount of data to use (both upload and download) per day, say 1 GB per day. After the connected device exhausts this limit, it might be given access to the Pi's network on a subscription model.

The logged details should include:

  • the IP given to the connected device by the DHCP server
  • the MAC address of the device (planning to use this attribute to uniquely identify the device and calculate its data usage over multiple sessions in a day)
  • Amount of data uploaded/downloaded per session
  • Details about each session, for each device, in a day

I want my device to automatically start logging these details without any human intervention. So, I assume that I need to do this using a script which has to be configured to run on startup. Any pointers on how to achieve this will be appreciated.

I hope I have succeeded in explaining the question clearly. Thanks!

  • What tool are you using for your 802.11 daemon ? and for the dns/dhcp ? The IP addr, hostname, macaddr, timestamp... can be found into the 'leases' file (one client per line). For the data uploaded/downloaded per session you must have a network sniffer (ex: wireshark with a filter for a specific network). Then use wireshark for show ALL informations about the network (use filtered IP of specific client). Example of another related network tool (ex: darkstat) – Ephemeral Aug 28 '19 at 17:05
  • @Ephemeral Sorry, I did not understand your question: What tool are you using for your 802.11 daemon ? and for the dns/dhcp ? I followed the steps at <raspberrypi.org/documentation/configuration/wireless/…>. I hope this answers your query. Using Wireshark is not what I am interested in. Isn't there any service available in Raspbian platform to get the stuff done? – flamingo_stark Aug 28 '19 at 17:48
  • Not be sorry, what program are you using for create the access point (hostapd?) and what program are you using for the dhcp server (isc-dhcp-server, dnsmasq?) ? – Ephemeral Aug 28 '19 at 17:51
  • 1
    @Ephemeral With the hints in your comment, I am in a better position to answer. For access point, it is hostapd. For dhcp server, it is dnsmasq. The static IP is configured using dhcpcd. – flamingo_stark Aug 28 '19 at 18:02
  • Ok then your are using hostapd and dnsmasq. For the clients informations you can parse the 'leases' file of dnsmasq in /var/lib/misc/dnsmasq.leases (output example) if you have not specified your own file in dnsmasq.conf. For network I don't know without sniffing the traffic. – Ephemeral Aug 28 '19 at 18:03

Your Answer

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

Browse other questions tagged or ask your own question.