Associated stations - making hostnames visible across multiple APs

Can you please tell which latest stable version this works on or which version this is known to be working?

How about you try to solve the issue, instead of going back to an old and unsupported version of Openwrt?

2 Likes

Any tips on where to start troubleshooting or what you think might be causing the issue?

The cron is getting posted in the system log as cron.err which is correct as someone noted in one of the previous comments in this thread

Sun Dec 22 14:30:00 2024 cron.err crond[1772]: USER root pid 6745 cmd scp /tmp/dhcp.leases root@192.168.86.245:/tmp/dhcp.leases

Bypass cron, run it manually, see if it does what it's supposed to ?

1 Like

It still doesn't work for some hostnames, there's a "?" next to macaddr

That's because the client doesn't send a name to dnsmasq when they request an IP.
That's not an Openwrt issue.

You can solve it by editing the /etc/ethers file, on every AP, if you got several.

When it is connected to the main router, those particular devices do give out name and listed correctly. Only on Dumb AP it goes with "?". I will look into /etc/ethers file later.

Anyway, so is cron the issue? How to fix it in 23.05.5
?

Then I guess the script isn't working?

We have no idea what's broken, can't work with "it doesn't work"

To be clear, cron isn't broken in 23.05.5.

This is normal. See:

In the future, please make a new thread for your issue about properly saving and running your script on devices.

2 Likes

thanks this is great

A hotplug script can be used instead of cron to trigger the dhcp.leases file mirroring whenever the DHCP leases change. Create a file in the /etc/hotplug.d/dhcp/ directory containing the following:

export HOME=/root
scp -o BatchMode=yes -p /tmp/dhcp.leases <otherhost>:/tmp/dhcp.leases

You'll need to have setup SSH keys for this like in the first post.

3 Likes

What’s the reason you chose to put the script in /root/wap/update_ethers.sh instead of directly in /etc/hotplug.d/dhcp/00-update-ethers?

No technical reason, in particular. I just happen to keep a number of WAP-related scripts in /root/wap/ and I have /root/ added into my /etc/sysupgrade.conf for convenience.

If someone desires to keep the script contents directly as part of the hotplug file, no harm in that.

1 Like

I’ve put a script in /etc/hotplug.d/dhcp/ directory but it’s never triggering. I’ve had devices request to renew their leases but the script doesn’t trigger. Any ideas why?

Can you share the script here in a code block?

1 Like

Same here. @_FailSafe or @infratl - how did you get it to work from hotplug? I'm running latest (24.10.3) but the hotplug script never actually runs.

SOLVED!

by @dave14305 -> Make sure you restart the dnsmasq service for this hotplug script to work!

sytemctl restart dnsmasq

I can see from logger that a DHCP request hits, but the hotplug script never fires

Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER([redacted]) XX:XX:XX:XX:XX:XX
Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPOFFER([redacted]) 10.10.30.101 XX:XX:XX:XX:XX:XX
Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPDISCOVER([redacted]) XX:XX:XX:XX:XX:XX
Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPOFFER([redacted]) 10.10.30.101 XX:XX:XX:XX:XX:XX
Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPREQUEST([redacted]) 10.10.30.101 XX:XX:XX:XX:XX:XX
Thu Oct  9 16:34:32 2025 daemon.info dnsmasq-dhcp[1]: DHCPACK([redacted]) 10.10.30.101 XX:XX:XX:XX:XX:XX [redacted-device-hostname]

Hotplug script is executable:

root@OpenWrt:~# ls /etc/hotplug.d/dhcp/00-sync-dhcp-hosts.sh
-rwxr-xr-x    1 root     root         343 Oct  9 16:41 /etc/hotplug.d/dhcp/00-sync-dhcp-hosts.sh

Running it from CLI works fine:

root@OpenWrt:~# /etc/hotplug.d/dhcp/00-sync-dhcp-hosts.sh
dhcp.leases                                                      100% 2758     2.7KB/s   00:00
root@OpenWrt:~#

And here's the script just for now:

#!/bin/sh
HOME=/root
USER=root
PORT=`awk -F "'" '/option Port/ {print $2}' /etc/config/dropbear`

scp -P $PORT /tmp/dhcp.leases root@10.10.10.2:/tmp/dhcp.leases
logger -t dhcp_host_sync -p notice "File '/tmp/dhcp.leases' copied to remote system"
echo `date` >> /root/dhcp_script.log

Thoughts?

Update: The problem was I hadn't restarted dnsmasq so hotplug wasn't firing. For anyone finding this in the future, after doing all the above setup, run this command:

sytemctl restart dnsmasq

and it should work!

2 Likes

Do you have a #!/bin/sh at the top of the script?

@dave14305 - I do have the shebang at top of script, still no help. Just missed it in the copy/paste to the post here. Fixed original post above.

Have you restarted dnsmasq since adding the hotplug script?

dnsmasq won't invoke hotplug unless it finds relevant scripts in hotplug.d during its startup.

@dave14305 - you are a genius. I hadn't restarted the dnsmasq service and after doing so it is working.