私は Mikrotik ルーター RB951G を 1 台持っています。次の 2 つのネットワークに 2 つのホットスポットを設定しています。
- 192.168.1.0/24
- 192.168.2.0/24
また、次の 2 つのユーザー プロファイルも作成しました。
- ゲスト
- 従業員
ゲストプロファイルに帯域幅制限を設定しました。一方、従業員プロファイルに毎日のデータダウンロード制限を設定したいと考えています。
そのためにこれら 2 つのスクリプトを実行しましたが、機能していないようです。
データを制限するスクリプト
#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 }
最後に、2 つのスケジュールを追加しました。
- データ制限をトリガーし、1 分ごとに実行されます。
クリアカウンターをトリガーし、24 時間ごとに実行されます。
24時間ごとに1回実行