You can use: cat /tmp/dhcp.leases | ssh <dumb ap ip> "cat > /tmp/dhcp.leases" -OR- scp /tmp/dhcp.leases root@<dumb ap ip>:/tmp/dhcp.leases Not both! Different command, same result.
(Remove # where it's necessary)
Don't forget to edit <main-router-ip> and <dumb-ap-ip> .
From my point of view, this method has a few disadvantages.
All dhcp leases are displayed on the Dumb AP in the overview, including those that actually have nothing to do with the Dumb AP.
In addition, no information is displayed about hosts that are entered as static hosts in the dhcp configuration, but are statically entered on the host.
It would therefore make sense to also transfer the /etc/ethers to the Dumb AP and to filter out only those entries from the /tmp/dhcp.leases of the main router that really connected.
First transfer dhcp.leases from main router to dhcp.leases.all on Dumb AP.
Create an extended ethers file on main router, including ip adresses.
Transfer to Dumb-AP also.
#!/bin/sh
# provice /etc/ethers for dumb-APs
STATIC="/etc/config/dhcp"
ETHERS="/tmp/ethers"
STATIC_DATE=$(date -r $STATIC +"%Y-%m-%d %H:%M:%S")
ETHERS_DATE=$(date -r $ETHERS +"%Y-%m-%d %H:%M:%S")
if [ "$STATIC_DATE" != "$ETHERS_DATE" ]; then
# date of DHCP config is newer then processed file
rm $ETHERS
# process DHCP config line by line
while IFS= read -r line || [ -n "$line" ]
do
# echo "LINE: $line"
# get Key Value
KEY="$(echo ${line} | cut -d' ' -f2 )"
if [ "$KEY" == "host" ]; then
NAM=""
MAC=""
IP=""
else
VAL="$(echo ${line} | cut -d' ' -f3 | cut -d\' -f2 )"
if [ "$KEY" == "name" ]; then
NAM="$VAL"
else
if [ "$KEY" == "ip" ]; then
IP="$VAL"
else
if [ "$KEY" == "mac" ]; then
MAC="$VAL"
fi
fi
fi
fi
if [ "$NAM" != "" ] && [ "$MAC" != "" ] && [ "$IP" != "" ]; then
echo "$MAC $NAM $IP" >> $ETHERS
NAM=""
MAC=""
IP=""
fi
done < $STATIC
# set date of ethers file to date of DHCP config
touch -d "$STATIC_DATE" $ETHERS
rm -f /tmp/scp_ethers.log
# tranfer newly created file to Dumb-AP's
logger "transfer file '/tmp/ethers' to all Dumb-AP's"
scp .....
fi
Finaly create a filtered /tmp/dhcp.leases on Dumb-AP
#!/bin/sh
# Shows MAC, IP address and any hostname info for all connected wifi devices
rm -rf /tmp/dhcp.leases
# list all wireless network interfaces
# (for universal driver; see wiki article for alternative commands)
for interface in `iwinfo | grep ESSID | cut -f 1 -s -d" "`
do
# for each interface, get mac addresses of connected stations/clients
maclist=`iwinfo $interface assoclist | grep dBm | cut -f 1 -s -d" "`
# for each mac address in that list...
for mac in $maclist
do
line="$(cat /tmp/dhcp.leases.all | grep -i $mac)"
# ... show the mac address:
if [ "$line" != "" ]; then
echo "$line" >> /tmp/dhcp.leases
else
# create dhcp like line for other devices
line="$(cat /tmp/ethers | grep -i $mac )"
name="$(echo $line | cut -d' ' -f2 )"
ip="$(echo $line | cut -d' ' -f3 )"
# 0000000000 means unlimited
echo "000000000 $mac $ip $name *" >> /tmp/dhcp.leases
fi
done
done
Not perfect but it seeme a little bit better to me ...
As you can see, chmod +x is not necessary. Just look at the other files in hotplug.
Maybe iface is wrong, it's probably too much. But it's good for testing. If you click on disconnect at a device in one router, the device should immediately connect to the other router/dumbap and trigger the hotplug/iface event.
Also because of my ssh settings I had to modify the scp line to define the port and the identity file:
scp -P 2020 -i /root/.ssh/id_dropbear_dumbap /tmp/dhcp.leases root@dumbap:/tmp/dhcp.leases
logger -t hotplug "File '/tmp/dhcp.leases' transferred from main to dumbap triggered by iface"
After running this setup for half an hour, I'm noticing way too many log entries with logread | grep hotplug, from 1 to 7 events per minute. I guess there's a host with major connection stability issues
Again, I want to emphasize using iface instead of dhcp to populate the dhcp.leases file is only useful for debugging!
I'm not very familar with ipv6.
Active DHCPv6 leases are stored in /tmp/hosts/ohdcp and can be transferred to a Dumb-AP too. Just as ipv4 leases.
But an adress given by SLAAC is not equal to DHCPv6!
Maybe you can fake an entry. But the content meaning will be wrong ...