Community discussions

MikroTik App
 
Blackfox12348888
just joined
Topic Author
Posts: 4
Joined: Mon Feb 27, 2023 5:44 pm

i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 5:48 pm

hi guys i have a hotspot set up and i want a script that runs every hour to check active users usage and removes the host of any user that exceeded 1gb is that possible?
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19107
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 6:05 pm

I think most folks use queues to limit downloading to discourage hogging of the internet connection.
If one is not able to monitor usage in such a way as to provide, it sounds like a functionality improvement suggestion.
Hopefully there is a relatively easy way to script this, if the information is available.

Have you considered the available HOTSPOT functionality and customisation.
It appears there is a built-in capability to limit bytes in both directions....
https://help.mikrotik.com/docs/display/ ... tomisation
 
Moba
Member Candidate
Member Candidate
Posts: 206
Joined: Sun Sep 27, 2020 6:15 pm

Re: i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 7:16 pm

The Hotspot functionality anav linked to might work.

Otherwise, you can use mangle to mark connections exceeding a set number of bytes and queue them so that the bandwidth limit available will discourage any heavy downloading. This method is detailed in the QoS thread - in reality, you can not only set a bulk priority for this traffic, but a hard limit on it as well. Few people will wait 16 hours to finish a download.

AFAIK, simple queues are used for accounting, but there's no way to limit data usage per user this way.

viewtopic.php?t=177559
 
Blackfox12348888
just joined
Topic Author
Posts: 4
Joined: Mon Feb 27, 2023 5:44 pm

Re: i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 7:52 pm

well my problem is if i set lets say 10gb to a user and the user used 9gb of them then the next time he opens the internet if he used the remaining 1 gb it wont automatically cut him off the internet it'll wait until he logs out or the host is removed somehow
 
Moba
Member Candidate
Member Candidate
Posts: 206
Joined: Sun Sep 27, 2020 6:15 pm

Re: i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 8:32 pm

Well, since I can now assume that you are selling vouchers with set limits, you should probably pay someone qualified to answer your question. My examples would work in a free access coffee shop scenario, where one would want to stop users from abusing the free service. User accounting and billing is something else.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: i want a script to remove hosts if they used 1gb

Mon Feb 27, 2023 10:18 pm

User accounting and billing is something else.
+10
 
reinerotto
Long time Member
Long time Member
Posts: 520
Joined: Thu Dec 04, 2008 2:35 am

Re: i want a script to remove hosts if they used 1gb

Wed Mar 01, 2023 8:23 am

well my problem is if i set lets say 10gb to a user and the user used 9gb of them then the next time he opens the internet if he used the remaining 1 gb it wont automatically cut him off the internet it'll wait until he logs out or the host is removed somehow
Using "serious" Captive Portal software on the router, i.g. "coova-chilli" (CP) on openwrt(OS), your functionality is no problem. It is implemented in coop between coova and freeradius, which does the traffic accounting and signals the drop of connection, in case traffic limit exceeded. One of the reasons, I abandoned mikrotiks hotspot many years ago, because too limited for "above basic" usage.
You can run openwrt plus coova on various mikrotiks, BTW.
However, "coova-chilli", used in various big money hotspot softwares, has a steep learning curve because of its large set of functions.

_MAY_BE_ you can do similar on mikrotiks hotspot stuff, because it also can be configured using radius.
 
User avatar
rumahnetmks
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Mon Dec 21, 2020 10:00 am

Re: i want a script to remove hosts if they used 1gb

Wed Mar 01, 2023 8:42 am

No need script, just use Mikrotik Hotspot with RADUS-UserManager, can do that limit via User-Manager Mikrotik Attribute "Mikrotik-Total-Limit" or simple using User-Manager>Limitation (since v7.5 ).
Limit reached, user will be disconnect without can connect again, except you set newly activated User-Manager User-Profile.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26322
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: i want a script to remove hosts if they used 1gb

Wed Mar 01, 2023 8:48 am

Yes, you can just use HotSpot with RADIUS CoA feature, to forcedly disconnect the user, when amount of X Gigabytes is exceeded. You will have to use a RADIUS server to keep your users. And it must have the CoA feature supported.
 
binooetomo
just joined
Posts: 17
Joined: Sat Nov 12, 2016 7:08 am

Re: i want a script to remove hosts if they used 1gb

Sat Mar 11, 2023 9:52 am

No need script, just use Mikrotik Hotspot with RADUS-UserManager, can do that limit via User-Manager Mikrotik Attribute "Mikrotik-Total-Limit" or simple using User-Manager>Limitation (since v7.5 ).
Limit reached, user will be disconnect without can connect again, except you set newly activated User-Manager User-Profile.
+1

Who is online

Users browsing this forum: itsbenlol and 35 guests