small-packages/luci-app-banmac-ipt/files/banmac/ban.sh
2026-05-10 09:48:30 +08:00

19 lines
645 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
sectionname=$(echo $0 | cut -d '_' -f 2 | sed 's/^OO!%!OO//')
getcmac=$(uci get banmac.$sectionname.banlist_mac | tr 'A-Z' 'a-z')
iptables -I FORWARD -m mac --mac-source $getcmac -j DROP
hostname=$(grep -n $getcmac /tmp/dhcp.leases | cut -d ' ' -f 4)
hostip=$(grep -n $getcmac /tmp/dhcp.leases | cut -d ' ' -f 3)
echo "★禁网设备:$hostname($hostip) MAC地址$getcmac 操作日期:$(date +%Y年%m月%d日\ %H点%M分%S秒)" >> /etc/banmaclog
for i in $(seq 0 1)
do
for x in $(iw wlan${i} station dump | grep -i station | cut -d ' ' -f 2)
do
if [ $x = $getcmac ]; then
iw dev wlan${i} station del $x
fi
done
done