我有一台 Mikrotik 路由器 RB951G。我在這兩個網路上設置了兩個熱點:
- 192.168.1.0/24
- 192.168.2.0/24
我還創建了兩個用戶設定檔:
- 客人
- 員工
我已在訪客設定檔上配置了頻寬限制。另一方面,我想在員工檔案上設定每日資料下載限制。
我已經運行這兩個腳本來執行此操作,但它似乎不起作用。
限制資料的腳本
#Set your dowload limit in MegaBYTES! :local downloadlimitmb "250" ### You will not need to edit anything below this line ### :local downloadlimit [($downloadlimitmb * 1048576)] :local counter :local datadown :local username :local macaddress :foreach counter in=[/ip hotspot active find where user~"^[T][-].{17}"] do={ :set $datadown [/ip hotspot active get $counter bytes-out] :if ($datadown>$downloadlimit) do={ :set $username [/ip hotspot active get $counter user] :set $macaddress [/ip hotspot active get $counter mac-address] /ip hotspot user remove [/ip hotspot user find where name=$username profile=Employee] /ip hotspot user add name=$username limit-bytes-out=$downloadlimit mac-address=$macaddress profile=Employee /ip hotspot active remove $counter :log info "Force logout on user: $username - Reached download quota" }}
用於清除使用者計數器的腳本
:log info "Checking Users" :local counter :foreach counter in=[/ip hotspot user find profile="Employee" ] do={ /ip hotspot user remove $counter }
最後我加入了兩個時間表:
- 觸發數據限制並每分鐘運行一次。
觸發清除計數器並每 24 小時運行一次。
每 24 小時運行一次