#! /bin/ash
EUIPAD="ff:fe"
ROUTER_ADDR=$(ip a s br-lan | awk '/inet6 [^f]+[^ec]+[^80]+[^0]+/{print $2}')
PREFIX=${ROUTER_ADDR%:1/64}
STATIC="";
(
for DH in $(awk -F= '/dhcp-host/{print $2}' /tmp/etc/dnsmasq.conf);
do
MAC="${DH%%,*}";
HOST="${DH##*,}";
STATIC="${STATIC:+${STATIC}|${HOST}}";
STATIC="${STATIC:-${HOST}}";
FIRSTBYTE=${MAC%%:*}
FIRSTBYTE=$(printf %02x $((0x$FIRSTBYTE|2)))
OTHERMANUF=${MAC%%:??:??:??}
OTHERMANUF=${OTHERMANUF#??:}
LOWMAC=${MAC#??:??:??:}
LOWMAC=${LOWMAC%:??}
LASTBYTE="${MAC//*:}"
EUI=${FIRSTBYTE}${OTHERMANUF}${EUIPAD}${LOWMAC}${LASTBYTE}
echo ${PREFIX}${EUI} ${HOST}
done;
for MH in $(awk 'BEGIN{i="'"${STATIC}"'"};$4!~i{print $2","$4}' /tmp/dhcp.leases);
do
MAC="${MH%%,*}";
HOST="${MH##*,}";
FIRSTBYTE=${MAC%%:*}
FIRSTBYTE=$(printf %02x $((0x$FIRSTBYTE|2)))
OTHERMANUF=${MAC%%:??:??:??}
OTHERMANUF=${OTHERMANUF#??:}
LOWMAC=${MAC#??:??:??:}
LOWMAC=${LOWMAC%:??}
LASTBYTE="${MAC//*:}"
EUI=${FIRSTBYTE}${OTHERMANUF}${EUIPAD}${LOWMAC}${LASTBYTE}
echo ${PREFIX}${EUI} ${HOST}
done
) > /tmp/hosts.ipv6;
killall -HUP dnsmasq;
mva
21.02.2013 21:52 N900
Do you really want to delete ?