原帖在恩山无线论坛 https://www.right.com.cn/forum/thread-8242242-1-1.html ========================================================================== 命令瞬间生效的,用了很久了。我的脚本如下,section 获取自luci的cbi,需要自己写luci配合使用: #!/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 ========================================================================== 现在的路由器运行openwrt, 知道设备的MAC地址,求教: 1. 上面的脚本如何修改才能实现定时从网络中踢掉指定MAC地址的设备 2. 脚本应该执行一次还是用crontab每天执行 感谢! |