在使用ddwrt tomato路由器配置全屋wifi时,会遇到客户端信号差但不断连的情况,使用以下脚本断开信号较差客户端的连接。
脚本来自https://git.losert.xyz/krypton/scripts/tree/master
#!/bin/sh ############################################## # This script disconnects connected clients, # # where the signal is below the configured # # signal. # ############################################## # v1.0 # # maintained by Rene Losert# ############################################## # https://git.losert.xyz/krypton/scripts/tree/master DEV=$(nvram show 2>&1 |grep ifname|grep 'wl[01]'|cut -d"=" -f2) # Defines the wlan interfaces (usally 2,4GHz & 5 GHz) SIGNAL="-80" # The Signal threshold, clients below get disconnected EXCLUDE="38:D5:47:62:F8:7A" # build an exclude for a wlan repeater key="$1" # get first parameter (currently only for debugging) if [[ "$key" == "-d" ]]; then echo "Signal Threshold: $SIGNAL" echo "Connected Clients:" fi while true; do date=$(date +"%a %b %e %H:%M:%S %Z %Y") for current in $DEV; do # for loop, for each wifi device (usaly this loop runs two times) CLIENTS=$(/usr/sbin/wl -a $current assoclist) # get the mac address of all connected clients at the current interface for MAC in $CLIENTS; do # for loop for each client (MAC) if [ $MAC != "assoclist" ]; then # the first line of assoclist, is indeed 'assoclist' which of course isn't a client ;-) SIG=$(/usr/sbin/wl -a $current rssi $MAC) # get the signal strengh of the current client if [[ "$key" == "-d" ]]; then echo "MAC: $MAC, Signal: $SIG"; fi # Printing client and signal strengh if in debugging mode if [[ ! "$MAC" = "$EXCLUDE" ]]; then # Proceed only, if client shouldn't be excluded if [ $SIG -lt $SIGNAL ]; then # Proceed if signal strengh is lower than configured signal threshold if [[ "$key" == "-d" ]]; then echo "$date: BELOW! Sending deauth to $MAC"; fi # further debugging output echo "$date: BELOW! Sending deauth to $MAC" >> /tmp/cleanup.log # Log all disconnects /usr/sbin/wl -a $current deauthenticate $MAC # Finally disconnect client fi # endif signal of client lower then threshold fi # endif exclude client fi #endif mac!=assoclist done # end loop for all connected clients done # end loop for interfaces if [[ "$key" == "-d" ]]; then echo "-----------------------------------"; fi #echo $date >> /tmp/cleanup.log sleep 5 done



