Send Connected Device to Email

Hi Guys,

I'm new with OpenWrt and working on a task that will allow the list of connected device's details to the router to be sent to an email. I'm having trouble on how I will get the list and where am I going to put my code in the router's directory? or is there any existing tutorial/guide that I can easily follow. :smile:

Thank you!!!

@JCE, welcome to the community!

iwinfo wlan0 assoclist will get the clients

1 Like

Look at this, https://www.reddit.com/r/openwrt/comments/5zqz9z/notify_on_unknown_wifi_client/
It helped me a lot

1 Like

This is great!!! Do you know how to also get the timestamp? Also, this might be a dumb question but where do I put in the code? do I have to put it in somewhere in the openwrt router directory/ is there any specific directory that I should put it?
Please bare with me :smile: I'm really new at this!
Thanks!!!

Thank you!!! will be trying this.
Also, I'm trying to get the IP address, timestamp, MAC address and the signal strength of the device then I'll send it to an email.
Please bare with me :smile:

try the date command

MAC address and the signal strength

iwinfo wlan0 assoclist

I assumed the OP meant the connection timestamp of the connecting client; but yes, that will pull the device's current time when the script is ran.

From your statement, I'm guessing you haven't ran the command yet. Feel free to run the command and let us know if that works for you.

For IP, you could cross reference against arp -a using diffutils but I noticed the characters are capital letters there.

You put it where you want it saved. Files and folders under /etc are persistent, folders under /tmp are gone upon reboot. We can't guess where you want the file, not a dumb question; but one that only you would know. Obviously, the script must go to a folder that survives a reboot.

1 Like

I actually used iw dev wlan0 station dump but yeah iwinfo wlan0 assoclist work fine too

I already tried the command. Thank you!!!

My problem now is to how to make the output of iw dev wlan0 station dump look like this:

IP address MAC Address Signal Timestamp
192.XXX.XXX.XX XX:XX:XX:XX XX XX:XX:XX

But I think this is not OpenWrt related anymore thanks Guys!!!

1 Like

Yeah, you will need to use the text processing tools such as grep, sed, awk, and a script for the logic.

1 Like