如何使用openwrt路由系統剔除弱信號設備?
在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