在github上有一段kickass.sh代码(bash脚本)https://github.com/Quenii/kickass
代码为:
#!/bin/bash while true; do maclist=(`iw dev wlan0 station dump | grep "Station" | cut -f 2 -s -d " "`) rxlist=(`iw dev wlan0 station dump | grep "signal:" | cut -f 3 -s -d " "`) #maclist=(`iwinfo wlan0 assoclist | grep "dBm" | cut -f 1 -s -d " "`) #rxlist=(`iwinfo wlan0 assoclist | grep "dBm" | cut -f 3 -s -d " "`) rxref="-80" #threshold len=${#maclist[@]} for((i=0;i<$len;i++)) do mac=${maclist[$i]} rx=${rxlist[$i]} # here, use string comparation, simple but error prone if [[ "$rx" > "$rxref" ]]; then #echo $mac $rx ubus call hostapd.wlan0 del_client ‘{"addr":"‘"$mac"‘", "reason": 5, "deauth": True, "ban_time": 3000}‘ #ubus call hostapd.wlan0 list_bans fi done sleep 1 done
使用方法:
1、执行opkg update,然后opkg install bash和opkg install iwinfo两条安装指令
2、将kickass.sh文件,下载到/usr/文件夹下面,修改权限为755.
chmod 755 /use/kickass.sh
3、修改程序代码中rxref的值为想要设置剔除的信号强度值;
4、/etc/re.local文件是openwrt系统启动执行的文件,在里面写上执行命令,即可在openwrt启动时执行命令:
bash kickass.sh
5、重启路由器之后,即可。
可通过iwinfo wlan0 assoclist 命令来查看客户端是否连接
相关参考链接:
http://www.newsmth.net/nForum/#!article/DigiHome/589750#_motz_
http://www.right.com.cn/FORUM/forum.php?mod=viewthread&tid=207711&page=1#pid1918514
原文地址:https://www.cnblogs.com/oneseven/p/8974740.html
时间: 2024-10-18 11:50:38