AVA Studio ID

lisensi

Iklan

AVA Studio
30 December 2022, 15:32 WITA (GMT+8)
Last Updated 2022-12-30T07:32:03Z

Script MikroTik RouterOS - Add a Data Limit To Trial Hotspot Users

Advertisement
Add a Data Limit To Trial Hotspot Users


To add a data limit to trial Hotspot users in Mikrotik RouterOS, you can use the following steps:
  1. Go to the "Hotspot" menu and click on the "Users" tab.
  2. Click the "Add" button to create a new Hotspot user.
  3. In the "Profile" field, select the trial profile that you want to use for the user. This profile should have the desired data limit and other parameters configured.
  4. Enter the username and password for the user in the appropriate fields.
  5. Click the "Apply" button to save the new user.
You can also use the "Hotspot User" page in the WebFig web interface to add new Hotspot users.

Keep in mind that you will need to set up a trial profile with the desired data limit and other parameters before you can assign it to trial users. To do this, go to the "Hotspot" menu and click on the "Profiles" tab. Click the "Add" button to create a new profile, and then configure the desired data limit and other parameters. Once you have created the trial profile, you can assign it to trial users as described above.

The following script allows you to assign a data limit to trial hotspot users and
a) have them kicked offline upon reaching this limit
b) create a temporary local user to stop them from logging back in again This is a feature which is not available via the current hotspot settings, so I decided to script it into existence. Enjoy! 

Script to check users for those over the limit: Make a scheduler entry to run this every X minutes, I'd recommend every 5-10 minutes.

#Download limit in MB
:local downquotamb "50"
# Do not modify anything below this line #
:local downquota [$downquotamb * 1000]
:local counter
:local datadown
:local username
:local macaddress
:foreach counter in=[/ip hotspot active find ] do={
:set datadown [/ip hotspot active get $counter bytes-out]
:if ($datadown>$downquota) 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]
/ip hotspot user add name=$username limit-bytes-out=$downquota mac-address=$macaddress
/ip hotspot active remove $counter
:log info "Logged out $username - Reached download quota"
}}

Script to clear all manually created user accounts; this can be done hourly, daily or weekly depending on your requirements.

:foreach counter in=[/ip hotspot user find ] do={/ip hotspot user remove \$counter}

Notes:
You can modify how often you want each of the script

No comments:

Post a Comment

Selamat Datang

X
X