Hostname propagation

hello,
on my main router, i set fix ip (Based on MAC) and hostname within section DHCP and DNS.

Is it possible to propagate that hostname of specific device to different openwrt "devices" = dumb APs? So i can see on dumb ap in section

Associated Stations

Network

MAC-Address

Host

the device hostname within Host column.

Thanks

you could populate /etc/ethers (on the AP)

@frollic thx, but there is no way to run some service as dns etc so these APs can fill the host name as hostname set on dns level.

what luci sections is responsible for /etc/ethers?

thx

not that I'm aware of ...

vi

There have been a number of topics in the forum about this subject and I've gleaned information from several of them. This is how I solved my issues. It may not be the best way but it does work on my network (Router and APs are running OpenWRT).

  1. I set static IP addresses for all devices I expect to be on my network on my Router in Network > DHCP and DNS > Static Leases.
  2. I run 3 dumb AP's - luci-app-commands, arp-scan and fping are installed on each one.
  3. After installing those three pieces of software you might have to reboot your APs.
  4. Once logged into Luci on your AP go to System > Custom Commands and create a command: arp-scan -qxlN -I br-lan | awk '{print $1}' | xargs fping -q -c1
  5. When you run the command it will say the command failed, but when you go to the Status > Overview > Associated Stations on your AP it will show all wireless devices listed with MAC, Hostname, and IP address, and which WLAN it is associated with.

Some folks have indicated that they run this command every few minutes via a cron job but I'm not sure how to do that.

1 Like

How I've done it...

Add entries to /etc/dnsmasq.conf

Example...

dhcp-host=E0:CB:1D:52:04:74,Kindle-Fire

Restart dnsmasq to take effect.

@OldNavyGuy
seems nice, but requires manual intervention and might be prone to bug/mistakes?

Not sure hows @jc1685 solution would be stable but i like it more. Whats the issue to add that to cron? I assume openwrt comes with cron jobs? Also what error it throws - if that command failed then it should not work?

thanks

Hey there!

I don't consider mac addresses and IP addresses to be private data, so I don't mind sharing them within my network without authentication or any other protection. So here's what I do.

My primary router with DHCP server enabled just publishes its current lease file via its web server.

ln -s /tmp/dhcp.leases /www/dhcp.leases

^^ This executed via SSH on my primary router allows me to download the current lease file via http://192.168.1.1/dhcp.leases from my primary router.

My Dumb APs just pull them in via cronjob

* *  * * *  wget http://192.168.1.1/dhcp.leases -O /tmp/dhcp.leases -q

^^ This goes to System -> Scheduled Tasks.

I had no issues so far. If anything, I'd expect the local DHCP server on a Dumb AP to update the leases file and going out of sync for a couple of seconds. But since the upstream leases are fetched every minute, that shouldn't be a huge problem.

My setup does not include ARP data. So if you have static IP addresses, those won't show up. Static DHCP rules, however, should work just fine. But if you go to e.g. the local network configuration of your laptop and type a static IP address right into your windows network settings, those are not covered.

Regarding the /etc/ethers file jc1685 suggested: I actually don't know if that file sits in a RAM mounted folder on my router or if it gets written to the internal flash drive every time it's updated. This indeed was a concern when I decided for my implementation.

Regards,
Stephan.

This is also what I use dumb APs. To be explicit as a cron scheduled task which is run every minute:

*/1 * * * * arp-scan -qxlN -I br-lan | awk '{print $1}' | xargs fping -q -c1

The only thing is I'm not sure why you're getting an error... Unless it's an oversight in your post, the command requires following packages (you are missing findutils-xargs and gawk unless they are install due to dependency/by other packages you have installed):

arp-scan findutils-xargs fping gawk

Just be aware that this is a recipe for command injection attacks and can't be considered to be safe (even in non-malicious cases, e.g. corrupted downloads due to connectivity issues).

Hey there.

To be honest, I fail a little to see what this could be. As long as I trust wget to just not execute the content it downloads and as log as I trust my router not to try execute the leases file even it it happens to be executable. The worst thing I imagined was some file format the dnsmasq would not understand.

But I'm all ears for a better way.

Would you consider using some grep expressions filtering all lines not matching my expected lease file format a sufficient counter measure?

Something like this:

* *  * * *  wget http://192.168.1.1/dhcp.leases -q -O- | awk '{ print $1 " " $2 " " $3 " " $4 }' | grep -i -e '^[0-9]\{10\} [0-9a-f]\{2\}\(:[0-9a-f]\{2\}\)\{5\} [0-9]\{1,3\}\(\.[0-9]\{1,3\}\)\{3\} [a-z0-9_-]\{1,32\}$' | awk '{ print $1 " " $2 " " $3 " " $4 " " $2}' > /tmp/dhcp.leases

This should, in my mind, only let those files pass that match "unixtimestamp macadress ipv4address hostname".

Regards,
Stephan.

Thanks for the tip @Edrikk. I'll check to see if findutils-xargs and gawk are installed. I know the other two are.

After installing findutils-xargs and gawk my AP is still throwing an error:

Command failed (Code: 31488)

Even though the error code is shown the command does what it is supposed to do. Maybe I'll try it as a cron job instead.

@Edrikk When I used your cron job I get an error in the System Log:

Thu Feb 24 13:27:00 2022 cron.err crond[26439]: USER root pid 26644 cmd arp-scan -qxlN -I br-lan | awk '{print $1}' | xargs fping -q -c1

Nevermind, I see here that all Busybox messages are written with an error code. I guess that doesn't mean there's an actual error.

Exactly. The cron "error" is not actually an error.
When you run the command on the shell prompt it should go through cleanly, which means it's working, and will work via cron as well.