根据信号强弱断开无线客户端连接的脚本

2020-03-05 – 5:44 下午 --- 645 次阅读

本脚本适用于 DD-WRT 和 Tomato,来源于: https://git.losert.xyz/krypton/Scripts/tree/master

适用于 LEDE/OpenWRT 的脚本在: https://gist.github.com/lg/e91d1c5c9640d963e13dbb1901bb4396

#!/bin/sh

##############################################
# This script disconnects connected clients, #
# where the signal is below the configured   #
# signal.                                    #
##############################################
# v1.0                                       #
# maintained by Rene Losert  #
##############################################
DEV=$(nvram show 2>&1 |grep ifname|grep 'wl[01]'|cut -d"=" -f2)
SIGNAL="-80"
EXCLUDE="38:D5:47:62:F8:7A"
key="$1"

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
CLIENTS=$(/usr/sbin/wl -a $current assoclist)
	for MAC in $CLIENTS; do    # for loop for each client (MAC)
		if [ $MAC != "assoclist" ]; then
			SIG=$(/usr/sbin/wl -a $current rssi $MAC)
			if [[ "$key" == "-d" ]]; then echo "MAC: $MAC, Signal: $SIG"; fi
			if [[ ! "$MAC" = "$EXCLUDE" ]]; then
				if [ $SIG -lt $SIGNAL ]; then
					if [[ "$key" == "-d" ]]; then echo "$date: BELOW! Sending deauth to $MAC"; fi
					echo "$date: BELOW! Sending deauth to $MAC" >> /tmp/cleanup.log
					/usr/sbin/wl -a $current deauthenticate $MAC
				fi
			fi

		fi
	done
done

if [[ "$key" == "-d" ]]; then echo "-----------------------------------"; fi
#echo $date >> /tmp/cleanup.log
sleep 5
done

:!: :!: :!:

点击显示引用框
引用本文,复制粘贴...

点击可把本文加入多个网络分享站点

您还可以参考以下文章:


您必须 登录 才能发表评论.