Odp: Luci- blokada dostępu do internetu w określonym czasie
To też jest jakieś rozwiązanie.
Czy dobrze dodałem drugiego HOSTA?
#!/bin/sh
HOST="AC:FD:CE:EA:73:7E"
HOST1="B8:3B:CC:51:95:6B"
# limit w minutach
LIMIT=5
F=/tmp/timequota-$HOST
if [ -e $F ]; then
USEDTIME=$(cat $F)
else
USEDTIME=0
fi
T=$(iw dev phy0-ap0 station dump | grep -i -A 1 $HOST | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy1-ap0 station dump | grep -i -A 1 $HOST | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy2-ap0 station dump | grep -i -A 1 $HOST | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy3-ap0 station dump | grep -i -A 1 $HOST | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy0-ap0 station dump | grep -i -A 1 $HOST1 | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy1-ap0 station dump | grep -i -A 1 $HOST1 | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy2-ap0 station dump | grep -i -A 1 $HOST1 | awk '/inactive time/{print $3}')
[ -z "$T" ] && T=$(iw dev phy3-ap0 station dump | grep -i -A 1 $HOST1 | awk '/inactive time/{print $3}')
[ -z "$T" ] && exit 0
if [ $T -lt 60000 ]; then
USEDTIME=$((USEDTIME + 1))
echo $USEDTIME > $F
fi
if [ $USEDTIME -gt $LIMIT ]; then
if [ "x$(uci -q get firewall.mac${HOST//:/}.enabled)" != "x1" ]; then
uci set firewall.mac${HOST//:/}=rule
uci set firewall.mac${HOST//:/}.src='lan'
uci set firewall.mac${HOST//:/}.dest='wan'
uci set firewall.mac${HOST//:/}.src_mac=$HOST
uci set firewall.mac${HOST//:/}.target='REJECT'
uci set firewall.mac${HOST//:/}.enabled=1
[ "x$(uci -q get firewall.mac${HOST1//:/}.enabled)" != "x1" ]; then
uci set firewall.mac${HOST1//:/}=rule
uci set firewall.mac${HOST1//:/}.src='lan'
uci set firewall.mac${HOST1//:/}.dest='wan'
uci set firewall.mac${HOST1//:/}.src_mac=$HOST1
uci set firewall.mac${HOST1//:/}.target='REJECT'
uci set firewall.mac${HOST1//:/}.enabled=1
uci commit firewall
/etc/init.d/firewall restart
fi
fi
exit 0